You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would there be interest in a feature that ensures all migrations have been run before contenting to load the app?
I am essentially thinking that every key in the migrations file should be present in the lapis_migrations table.
I'm not sure if I'll do this soon, but I would be happy to attempt a PR at some point. :)
The text was updated successfully, but these errors were encountered:
I believe Lapis currently executes migrations until it finishes all migrations or hits an error, at which point it bails and continues on loading the app. Halting app load if migrations fail would probably be a nice feature to add but a larger issue is that migrations do not currently use transactions so if a migration function fails, it permanently fails and gets skipped if attempting to re-run migrations. furthermore, the half-executed migration is not rolled back leading to a lot of manual tinkering during development which is most certainly a pain.
If you or anyone else is planning to poke at migrations, I'd request wrapping each migration function in a transaction BEFORE that function gets added to the executed list so that if it fails, it can be completely rolled back to the last successful function.
return {
[1] =function()
db.query("select * from users")
end,
[2] =function()
db.query("select * from hurray for syntax errors!")
end
}
in the above migration, what i would expect would be:
TRANSACTION
INSERT INTO migrations (func) VALUES (1)
> execute function
if success then
COMMIT
else
ROLLBACK
end
TRANSACTION
INSERT INTO migrations (func) VALUES (2)
> execute function
if success then
COMMIT
else
ROLLBACK
end
I could see there maybe being an --assert-migrations flag on the lapis server and lapis build commands, this would fail to start/send signal to server unless it's confirmed that migrations have been run
Would there be interest in a feature that ensures all migrations have been run before contenting to load the app?
I am essentially thinking that every key in the migrations file should be present in the
lapis_migrations
table.I'm not sure if I'll do this soon, but I would be happy to attempt a PR at some point. :)
The text was updated successfully, but these errors were encountered: