Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If there are pending migrations, tell the app to shut down #737

Merged
merged 2 commits into from
Oct 9, 2021

Conversation

jwoertink
Copy link
Member

Fixes #671
Fixes luckyframework/lucky#1142

This PR adds a front and center error when there's pending migrations.

Before PR:

After PR:

Screen Shot 2021-10-03 at 9 24 56 AM

there is one minor issue still here which is if you boot your app locally without a process manager (e.g. crystal src/start_server.cr), it will try to send interrupt signals to the parent process.
Screen Shot 2021-10-03 at 9 25 35 AM

Most likely this isn't a big issue. You can even just run lucky watch and it's fine. It's only when booting the app manually through crystal.

@robacarp
Copy link
Contributor

robacarp commented Oct 5, 2021

Does this set of changes alter how a booting production-mode app would behave when database migrations are pending?

@jwoertink
Copy link
Member Author

Well, by default, this would only run in development. For production, you have a few different options of either building the migrate task and manually running that, or changing the linked code to look more like:

if LuckyEnv.development?
  Avram::Migrator::Runner.new.ensure_migrated!
  Avram::SchemaEnforcer.ensure_correct_column_mappings!
else
  Avram::Migrator::Runner.new.run_pending_migrations
end

but the ensure_migrated! method would still only run for development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make pending migration error a little more noticable Webpage hangs if there's a pending migration
3 participants