From efc989180e952f54429e2849a5792ddab328f39d Mon Sep 17 00:00:00 2001 From: Maple Ong Date: Tue, 11 Jul 2023 14:55:11 -0400 Subject: [PATCH] Inherit from AR SchemaMigration directly --- lib/data_migrate/data_schema_migration.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/data_migrate/data_schema_migration.rb b/lib/data_migrate/data_schema_migration.rb index 68316664..c04c470e 100644 --- a/lib/data_migrate/data_schema_migration.rb +++ b/lib/data_migrate/data_schema_migration.rb @@ -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