Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ETX-2221] Rails 7.2 support - migrations_paths can vary #6

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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