Add migration to post-deploy script (#151)

This commit is contained in:
Justin Edmund 2025-01-13 06:36:01 -08:00 committed by GitHub
parent 1d6dff18de
commit df7454af4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,7 @@ class PostDeploymentManager
end
def run
migrate_database
import_new_data
display_import_summary
download_images
@ -29,6 +30,24 @@ class PostDeploymentManager
private
def migrate_database
log_header 'Running database migrations...', '-'
puts "\n"
if @test_mode
log_step "TEST MODE: Would run pending migrations..."
else
ActiveRecord::Migration.verbose = @verbose
version = ActiveRecord::Migrator.current_version
ActiveRecord::Tasks::DatabaseTasks.migrate
new_version = ActiveRecord::Migrator.current_version
if version == new_version
log_step "No pending migrations."
else
log_step "Migrated from version #{version} to #{new_version}"
end
end
end
def import_new_data
log_header 'Importing new data...'
puts "\n"