prevent the server from starting if database isn't migrated

This commit is contained in:
Jill 2023-01-04 02:39:14 +03:00
parent 2c4ddaf0e8
commit 27d82b509c
1 changed files with 8 additions and 3 deletions

View File

@ -193,13 +193,18 @@ module CrystalGauntlet
parser.parse
migrator = Migrate::Migrator.new(
DATABASE
)
if migrate
LOG.info { "Migrating #{ENV["DATABASE_URL"].colorize(:white)}..." }
migrator = Migrate::Migrator.new(
DATABASE
)
migrator.to_latest
else
if !migrator.latest?
LOG.fatal { "Database hasn\'t been migrated!! Please run #{"crystal-gauntlet migrate".colorize(:white)}" }
end
server = HTTP::Server.new([
HTTP::LogHandler.new,
HTTP::StaticFileHandler.new("public/", fallthrough: true, directory_listing: false),