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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/avram/migrator/runner.cr
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,28 @@ class Avram::Migrator::Runner

def ensure_migrated!
if !pending_migrations.empty?
raise "There are pending migrations. Please run lucky db.migrate"
display_migration_error_banner
Process.signal(:term, Process.ppid)
exit 1
end
end

private def display_migration_error_banner
puts ""
puts error_background
puts pending_migrations_error.colorize.on_red.white
puts error_background
puts ""
end

private def pending_migrations_error
" There are pending migrations. Please run lucky db.migrate "
end

private def error_background
(" " * pending_migrations_error.size).colorize.on_red
end

private def migrated_migrations
@@migrations.select &.new.migrated?
end
Expand Down