Open ScottFreeCode opened 2 years ago
One thing that may need to be used from the defaults file before starting the service is to create the named DB in the first place, as services typically connect to a specific named DB and may fail if it is not present. This isn't even SQL, of course.
I believe the order of effects when starting up the mocks and services with mysql set to snapshot DBs is:
(The same order is used without snapshotting DBs, with similar questions/issues but it's eclipsed by the migrations getting wiped so with migrations one pretty much always wants to snapshot DBs.)
This has a couple limitations/oddities:
In other words, you can have migrations or defaults but effectively it's hard to use both, e.g. to populate default data in tables the service creates.
It would make sense in my opinion to defer running the defaults until after the services start, to the same point when the DB is snapshotted (presumably before the snapshot, although at that point as long as the defaults don't contain nondeterministic values/behavior there is only performance difference between "defaults once then snapshot" versus "snapshot migrations, reapply snapshot in place of wiping DB and reapply defaults after each wipe or snapshot application".)