Skip to content

Commit 3d10cd9

Browse files
[ETX-221] Support Rails 7.2
1 parent 9f0b137 commit 3d10cd9

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

lib/rails_data_migrations/log_entry.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ def self.table_name
77
end
88

99
def self.create_table
10+
schema_migration_instance.create_table
11+
end
12+
13+
def self.schema_migration_instance
1014
connection_pool = ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool
1115
schema_migration = ActiveRecord::SchemaMigration.new(connection_pool)
12-
schema_migration.define_singleton_method(:table_name) { ::RailsDataMigrations::LogEntry.table_name }
13-
schema_migration.create_table
16+
schema_migration.define_singleton_method(:table_name) { LogEntry.table_name }
17+
schema_migration.instance_variable_set(:@arel_table, Arel::Table.new(LogEntry.table_name))
18+
schema_migration
1419
end
1520
end
1621
end

lib/rails_data_migrations/migrator.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ def list_pending_migrations
4444

4545
def run_migration(direction, version)
4646
connection_pool = ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool
47-
schema_migration = ActiveRecord::SchemaMigration.new(connection_pool)
48-
schema_migration.define_singleton_method(:table_name) { ::RailsDataMigrations::LogEntry.table_name }
4947
internal_metadata = ActiveRecord::InternalMetadata.new(connection_pool)
50-
new(direction, list_migrations, schema_migration, internal_metadata, version).run
48+
new(
49+
direction,
50+
list_migrations,
51+
LogEntry.schema_migration_instance,
52+
internal_metadata,
53+
version
54+
).run
5155
end
5256
end
5357
end

0 commit comments

Comments
 (0)