3 ms·
I would say automatic migration generation isn’t a necessary or particularly important part of an ORM. ORMs are there to map your database relational objects to
by teaearlgraycold 1y ago
I would say automatic migration generation isn’t a necessary or particularly important part of an ORM. ORMs are there to map your database relational objects to your client language’s objects.
- cjs_ac 1y agoI think the person you're replying to is arguing for using some sort of database migration library without using an ORM library. It's the same position I came to recently.
- teaearlgraycold 1y agoYes but they seem to have switched because they didn’t like ORM-generated migration code. I think that’s a bad reason to switch because it wasn’t an important part of ORMs in the first place. Basically, I want to know why they were even using ORMs before. I don’t want to go without an ORM because I’ll end up making one ad-hoc anyway. I’m not going to do work on raw tuples in my application code.
- Tostino 1y agoI'd call it an anti-feature for most long-lived projects that will end up needing migrations through its lifetime. I go the liquibase route for migrations, and just use the mapping portion of any ORM.
- pphysch 1y agoMost(?) devs nowadays are introduced to database migration tools as a DX feature. "Wow, 1-2 command and my app and database are in sync!" In reality, migration tools are 100% about data loss prevention. If you do not care about data loss, updating your schema is trivial, just drop everything and create. Dev environments should be stateless anyways, using separate data "fixtures" when needed. Data loss itself is a highly nuanced topic. Some data is replaceable, some might be protected in a separate store. So I agree that ORMs should challenge the assumption that automatic migration tools need to be part of their kitchen sink.
- teaearlgraycold 1y agoI like that they provide the basic structure of how to apply yet unseen migrations. But they don’t need to generate the SQL at all. You quickly learn to never trust the generated code. It always needs to be manually reviewed.
- wagwang 1y agoThe ORM auto migration tools are a 100% a DX feature. Obviously any serious application will have complicated migrations that outgrow the generated sql; doesn't mean its not a nice to have feature for quick iteration.
- pphysch 1y agoI largely agree, but the cargo-culting around every migration operation being "reversible" suggests everyone isn't on the same page here. Too much straddling of the line (gulf) between DX tool and production data management tool.
- solarkraft 1y agoBut that’s close to the same thing. No data loss is a non negotiable (or very expensive) requirement, so we have to make migrations work somehow.