Skip to content

Commit

Permalink
[ETX-2221] Rails 7.2 support - migrations_paths can vary
Browse files Browse the repository at this point in the history
[ETX-2221] Rails 7.2 support - migrations_paths can vary
  • Loading branch information
mmurphy-notarize authored Sep 13, 2024
2 parents 2fa72da + dd00c84 commit 1ec8bf9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/generators/data_migration_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DataMigrationGenerator < Rails::Generators::NamedBase

def create_migration_file
migration_file_name =
"#{RailsDataMigrations::Migrator.migrations_path}/#{Time.now.utc.strftime('%Y%m%d%H%M%S')}_#{file_name}.rb"
"#{RailsDataMigrations::Migrator.migrations_paths.first}/#{Time.now.utc.strftime('%Y%m%d%H%M%S')}_#{file_name}.rb"
copy_file 'data_migration_generator.rb', migration_file_name do |content|
content.sub(/ClassName/, file_name.camelize)
end
Expand Down
6 changes: 4 additions & 2 deletions lib/rails_data_migrations/migrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

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

MIGRATOR_SALT = 2053462855

def record_version_state_after_migrating(version)
Expand Down Expand Up @@ -33,6 +31,10 @@ def schema_migrations_table_name
LogEntry.table_name
end

def migrations_paths
[ENV.fetch('DATA_MIGRATIONS_PATH', 'db/data_migrations')]
end

def list_migrations
::ActiveRecord::MigrationContext.new(migrations_paths).migrations
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_data_migrations/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RailsDataMigrations
VERSION = '1.3.0.3'
VERSION = '1.3.0.4'
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
RailsDataMigrations::LogEntry.delete_all

# stub migrations folder
allow(RailsDataMigrations::Migrator).to receive(:migrations_path).and_return('spec/db/data-migrations')
allow(RailsDataMigrations::Migrator).to receive(:migrations_paths).and_return(['spec/db/data-migrations'])

# remove migration files
`rm -rf spec/db/data-migrations`
Expand Down

0 comments on commit 1ec8bf9

Please sign in to comment.