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

Upstream and allow engines #244

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion lib/data_migrate/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ def config
end

class Config
attr_accessor :data_migrations_path, :data_template_path, :db_configuration, :spec_name
attr_accessor :data_migrations_path, :data_migrations_gen_path, :data_template_path, :db_configuration, :spec_name

DEFAULT_DATA_TEMPLATE_PATH = "data_migration.rb"

def initialize
@data_migrations_path = "db/data/"
@data_migrations_gen_path = "db/data"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does gen stand for? do you mind adding it to the docs as well. also, please rebase with main, at some point travisci tests stopped running to i switched to github actions

@data_template_path = DEFAULT_DATA_TEMPLATE_PATH
@db_configuration = nil
@spec_name = nil
Expand Down
2 changes: 1 addition & 1 deletion lib/data_migrate/data_migrator_five.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module DataMigrate
class DataMigrator < ActiveRecord::Migrator
def self.migrations_paths
[DataMigrate.config.data_migrations_path]
Array.wrap(DataMigrate.config.data_migrations_path)
end

def self.assure_data_schema_table
Expand Down
10 changes: 6 additions & 4 deletions lib/data_migrate/data_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ def migrated

def versions
@versions ||= begin
versions = []
Dir.foreach(DataMigrate::DataMigrator.full_migrations_path) do |file|
match_data = DataMigrate::DataMigrator.match(file)
versions << match_data[1].to_i if match_data
versions = Set.new
DataMigrate::DataMigrator.migrations_paths.each do |path|
Dir.foreach(path) do |file|
match_data = DataMigrate::DataMigrator.match(file)
versions << match_data[1].to_i if match_data
end
end
versions
end
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/data_migration/data_migration_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def data_migrations_file_path
end

def data_migrations_path
DataMigrate.config.data_migrations_path
DataMigrate.config.data_migrations_gen_path || DataMigrate.config.data_migrations_path
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

context 'when custom data migrations path has a trailing slash' do
before do
DataMigrate.config.data_migrations_path = 'abc/'
DataMigrate.config.data_migrations_gen_path = 'abc/'
end

it 'returns correct file path' do
Expand All @@ -50,7 +50,7 @@

context 'when custom data migrations path does not have a trailing slash' do
before do
DataMigrate.config.data_migrations_path = 'abc'
DataMigrate.config.data_migrations_gen_path = 'abc'
end

it 'returns correct file path' do
Expand Down