Replies: 3 comments 10 replies
-
|
Hello @bok- :) Wow, 193 migrations is a lot! Your question is certainly relevant. The strategy you describe looks sensible to me. You name the collapsed migration like the last one, and this sounds good. You have thought of people who may need a special case. Some tests will help you making sure various scenarios are handled as expected. The raw result of sqlite_master might need some massage, in case SQLite would be sensitive about the order of applied statements. I had some success trying your strategy against the result of Take care that if the database still contains the identifiers of old migrations, the methods that query migrations will be confused by the unknown obsolete migration names. These methods will return unexpected results, with various nefarious consequences, even if you do not call them directly. I recommend that the collapsed migration removes the names of obsolete migrations. To do so, delete rows in the The name and schema of this table is supposedly private. I'll add a public api soon. You don't have to wait for me though: just delete and call it a day, I'll tell you when a public api is ready. |
Beta Was this translation helpful? Give feedback.
-
|
⛵ Merged migrations have shipped in v7.8.0 |
Beta Was this translation helpful? Give feedback.
-
|
I'm curious to understand how you guys manage 193 migrations in your app:
(Sorry if this is an obvious question. I'm trying if I need to anticipate certain things like this "merge migration" for the future, I'm only at 30 migrations.) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I just wanted to double check something that I've been thinking about for a while, in case my understanding is very wrong.
We're at 193 migrations at the time of posting in a project I'm a part of (there are ~80 developers) and applying those migrations takes about 300-500 milliseconds depending on device, which adds up in unit tests and in the collective user experience.
I've been thinking about collapsing migrations that are 12+ months old into a single one in order to speed things up. That's well beyond our typical support period of 6 months, so while anyone who hasn't updated the app in more than 12 months would get a slightly worse experience we we delete and re-create the database, most people would not be impacted.
So I wanted to check my logic here. If I have 6 migrations:
If I want to collapse migrations 1-4 into a single one I can:
4.SELECT sql FROM sqlite_schemato get the schema at that point in time.4with the captured schema.Giving the following:
This would mean anyone who has already applied migrations 5+ would not notice any difference, but anyone creating a new database would only apply migrations 4-6, but ultimately the schema of the database would still be identical in both cases.
Would that work, or have I missed something fundamental?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions