Skip to content

Commit

Permalink
Merge pull request #275 from ilyakatz/inherit-from-schema-migration
Browse files Browse the repository at this point in the history
Inherit from ActiveRecord::SchemaMigration directly
  • Loading branch information
wildmaples authored Jul 11, 2023
2 parents 7bc28b8 + efc9891 commit 72e719d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/data_migrate/data_schema_migration.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
module DataMigrate
class DataSchemaMigration
class DataSchemaMigration < ActiveRecord::SchemaMigration
class << self
delegate :table_name, :primary_key, :create_table, :normalized_versions, :create, :create!, :table_exists?, :exists?, :where, to: :instance
def table_name
ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix
end

def instance
@instance ||= Class.new(::ActiveRecord::SchemaMigration) do
define_singleton_method(:table_name) { ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix }
define_singleton_method(:primary_key) { "version" }
end
def primary_key
"version"
end
end
end
Expand Down

0 comments on commit 72e719d

Please sign in to comment.