-
Notifications
You must be signed in to change notification settings - Fork 196
/
Copy pathdata_schema_migration.rb
31 lines (28 loc) · 993 Bytes
/
data_schema_migration.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module DataMigrate
class DataSchemaMigration < ActiveRecord::SchemaMigration
# In Rails 7.1+, ActiveRecord::SchemaMigration methods are instance methods
# So we only load the appropriate methods depending on Rails version.
if DataMigrate::RailsHelper.rails_version_equal_to_or_higher_than_7_1
def table_name
ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix
end
def primary_key
"version"
end
else
class << self
def table_name
ActiveRecord::Base.table_name_prefix + 'data_migrations' + ActiveRecord::Base.table_name_suffix
end
def primary_key
"version"
end
def create_version(version)
# Note that SchemaMigration.create_version in Rails 7.1 does not
# raise an error if validations fail but we retain this behaviour for now.
create!(version: version)
end
end
end
end
end