Skip to content

Commit

Permalink
[ETX-221] Support Rails 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mmurphy-notarize committed Sep 12, 2024
1 parent 62cceaf commit d967d74
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/rails_data_migrations/log_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module RailsDataMigrations
class LogEntry < ::ActiveRecord::Base
def self.table_name
ENV.fetch("DATA_MIGRATIONS_TABLE_NAME", "data_migrations")
ENV.fetch('DATA_MIGRATIONS_TABLE_NAME', 'data_migrations')
end

def self.create_table
Expand Down
6 changes: 3 additions & 3 deletions lib/rails_data_migrations/migrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module RailsDataMigrations
class Migrator < ::ActiveRecord::Migrator
self.migrations_paths = [ENV.fetch("DATA_MIGRATIONS_PATH", "db/data_migrations")]
self.migrations_paths = [ENV.fetch('DATA_MIGRATIONS_PATH', 'db/data_migrations')]

MIGRATOR_SALT = 2053462855

Expand All @@ -17,7 +17,7 @@ def record_version_state_after_migrating(version)
end

class << self
def get_all_versions
def get_all_versions # rubocop:disable Naming/AccessorMethodName
if LogEntry.table_exists?
LogEntry.all.map { |x| x.version.to_i }.sort
else
Expand All @@ -42,7 +42,7 @@ def list_pending_migrations
list_migrations.reject { |m| already_migrated.include?(m.version) }
end

def run_migration(direction, migrations_path, version)
def run_migration(direction, version)
schema_migration = ::ActiveRecord::Base.connection_pool.schema_migration
schema_migration.define_singleton_method(:table_name) { ::RailsDataMigrations::LogEntry.table_name }
internal_metadata = ::ActiveRecord::Base.connection_pool.internal_metadata
Expand Down
6 changes: 1 addition & 5 deletions lib/tasks/data_migrations.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ namespace :data do
def apply_single_migration(direction, version)
raise 'VERSION is required' unless version

RailsDataMigrations::Migrator.run_migration(
direction,
RailsDataMigrations::Migrator.migrations_path,
version.to_i
)
RailsDataMigrations::Migrator.run_migration(direction, version.to_i)
end

task init_migration: :environment do
Expand Down
1 change: 0 additions & 1 deletion spec/data_migrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

describe RailsDataMigrations do
it 'checks for migration log table existence' do
expect(RailsDataMigrations::Migrator.migrations_table_exists?(ActiveRecord::Base.connection)).to be_truthy
expect(RailsDataMigrations::Migrator.get_all_versions).to be_blank
end

Expand Down

0 comments on commit d967d74

Please sign in to comment.