4 ms·
> What is so hard in writing table migration, it is like a few minutes of your time. I have worked on a number of large enterprise projects where there were hu
by threeseed 9y ago
> What is so hard in writing table migration, it is like a few minutes of your time.
I have worked on a number of large enterprise projects where there were hundreds and hundreds of migrations over the lifespan. I have never seen it take minutes of time. Or maybe you're just one of those fun developers who never properly tested their work.
But I have definitely seen production outages and subsequent failures to rollback because of edge cases between various individual migrations.
- StavrosK 9y agoI have worked on tens of projects in the past decade, and I have very rarely seen migrations be anything other than automatic, taking one command to be generated.
- threeseed 9y agoFor basic schema changes maybe. But often you are adding to reference data or running a transform SQL in order to produce some new denormalised table or the huge array of changes needed to support new use cases. These can't be automated and are hugely error prone.
- zaarn 9y agoIf your Schema is properly setup after the initial changes to it, then it's not error prone at all, it's doing what it's supposed to do. Unless you migration involves "disable all checks, add new columns/tables, move and delete old data, enable all checks" If you are migrating to a denormalised table then it should obviously crash when your conversion tool is doing something wrong and the RDBMS just prevented it from succeeding in doing something wrong. If your migration is actually error prone as in "mangling and corrupting" data I suggest you are doing something wrong and you probably disabled the safety checks in your RDBMS.
- StavrosK 9y agoHow do schemaless databases make this easier?
- saiya-jin 9y agoImagine a core banking system system migration - few TB of data, few thousand of tables, various background processes for different purposes over them, 0 margin for error. Usually 10-20 people working on dev side, same amount of testing. Impossible to not have issues. If you say you deliver these kind of projects with 1 command, then we're talking about very different scales of projects (mine is rather 100 page runbook for DB admins)
- ssijak 9y agoWhat is the problem of hundreds or even thousands of migrations?? Point of writing migration files is that you can start from empty database, execute every migration file and end up with the current production database structure. So If you have 1000 migration files, writing 1000 and first is easy for the current sprint, you have state X and just need to write a diff for the next state. And I have written many migrations in systems with tens of different db`s/schemas in the same project which could be different based on the geographical region or some other requirement and never had any big problem
- threeseed 9y agoI understand what migrations are. I just disagree that they are trivial. Especially since you need to write the rollback script as well. And then test it with data. And then ensure there are no weird interactions with other migrations. Because if there is a problem with any one of them then it can be a huge headache to unwind everything.
- ssijak 9y agoMost of the migrations do not involve fiddling with data (for example adding a column, table). But if they do, yes you will spend more time on them. But it will be on the order of magnitude better then doing the same thing in MongoDB where you just have implicit schema