Open sanel opened 8 years ago
At what point would we use this API though?. Would we use it every time we deploy the server or only on occasions when we know we need to do a migration. Its an Asynchronous API so I say its best to do it before we deploy any migrations.
It make sense to use it only when Flyway detect actual schema changes. There is a method called DescribeDBSnapshots that returns status of current snapshots and we can extract value of Status
field. From what I can see, snapshot in working will have creating
value...
Its an Asynchronous API so I say its best to do it before we deploy any migrations.
If you think about manual, explicit operation, I'd go with it as last resort. It is easy to forget when one of us update schema and remember to invoke migration on deploy phase (taking into account testing, this can take day/two/three).
I envision this scenario: let the app try to create snapshot, run migration, if migration fails, try to restore snapshot. If that fails, just report with big red text that something went bad. However, this needs to have one significant addon, no matter if we run migration manually or automatically: pav-api
should go to 'maintenance' phase during migration, to prevent accidental data writing that could damage db integrity.
Flyway does not support rollbacks of failed migrations, but AWS gives API for triggering DB snapshots (http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_CreateSnapshot.html).
With proper env variable (so it can be run on Convox only), this could be called before each migration (if detected that migration will actually be run).