Compare commits
1 commit
main
...
jedmund/do
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d4915890f |
1 changed files with 24 additions and 1 deletions
|
|
@ -18,7 +18,7 @@ module PostDeployment
|
|||
if @test_mode
|
||||
simulate_migrations
|
||||
else
|
||||
perform_migrations
|
||||
perform_migrations_in_order
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -83,5 +83,28 @@ module PostDeployment
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def perform_migrations_in_order
|
||||
schema_context = ActiveRecord::Base.connection.migration_context
|
||||
schema_migrations = schema_context.migrations
|
||||
|
||||
data_migrations_path = DataMigrate.config.data_migrations_path
|
||||
data_context = DataMigrate::MigrationContext.new(data_migrations_path)
|
||||
data_migrations = data_context.migrations
|
||||
|
||||
all_migrations = (schema_migrations + data_migrations).sort_by(&:version)
|
||||
|
||||
all_migrations.each do |migration|
|
||||
if migration.filename.start_with?(data_migrations_path)
|
||||
say "Running data migration: #{migration.name}"
|
||||
# Run the data migration (you might need to call `data_context.run(migration)` or similar)
|
||||
data_context.run(migration)
|
||||
else
|
||||
say "Running schema migration: #{migration.name}"
|
||||
# Run the schema migration (Rails will handle this for you)
|
||||
schema_context.run(migration)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue