File tree Expand file tree Collapse file tree 4 files changed +5
-10
lines changed Expand file tree Collapse file tree 4 files changed +5
-10
lines changed Original file line number Diff line number Diff line change 3
3
module RailsDataMigrations
4
4
class LogEntry < ::ActiveRecord ::Base
5
5
def self . table_name
6
- ENV . fetch ( " DATA_MIGRATIONS_TABLE_NAME" , " data_migrations" )
6
+ ENV . fetch ( ' DATA_MIGRATIONS_TABLE_NAME' , ' data_migrations' )
7
7
end
8
8
9
9
def self . create_table
Original file line number Diff line number Diff line change 2
2
3
3
module RailsDataMigrations
4
4
class Migrator < ::ActiveRecord ::Migrator
5
- self . migrations_paths = [ ENV . fetch ( " DATA_MIGRATIONS_PATH" , " db/data_migrations" ) ]
5
+ self . migrations_paths = [ ENV . fetch ( ' DATA_MIGRATIONS_PATH' , ' db/data_migrations' ) ]
6
6
7
7
MIGRATOR_SALT = 2053462855
8
8
@@ -17,7 +17,7 @@ def record_version_state_after_migrating(version)
17
17
end
18
18
19
19
class << self
20
- def get_all_versions
20
+ def get_all_versions # rubocop:disable Naming/AccessorMethodName
21
21
if LogEntry . table_exists?
22
22
LogEntry . all . map { |x | x . version . to_i } . sort
23
23
else
@@ -42,7 +42,7 @@ def list_pending_migrations
42
42
list_migrations . reject { |m | already_migrated . include? ( m . version ) }
43
43
end
44
44
45
- def run_migration ( direction , migrations_path , version )
45
+ def run_migration ( direction , version )
46
46
schema_migration = ::ActiveRecord ::Base . connection_pool . schema_migration
47
47
schema_migration . define_singleton_method ( :table_name ) { ::RailsDataMigrations ::LogEntry . table_name }
48
48
internal_metadata = ::ActiveRecord ::Base . connection_pool . internal_metadata
Original file line number Diff line number Diff line change @@ -6,11 +6,7 @@ namespace :data do
6
6
def apply_single_migration ( direction , version )
7
7
raise 'VERSION is required' unless version
8
8
9
- RailsDataMigrations ::Migrator . run_migration (
10
- direction ,
11
- RailsDataMigrations ::Migrator . migrations_path ,
12
- version . to_i
13
- )
9
+ RailsDataMigrations ::Migrator . run_migration ( direction , version . to_i )
14
10
end
15
11
16
12
task init_migration : :environment do
Original file line number Diff line number Diff line change 4
4
5
5
describe RailsDataMigrations do
6
6
it 'checks for migration log table existence' do
7
- expect ( RailsDataMigrations ::Migrator . migrations_table_exists? ( ActiveRecord ::Base . connection ) ) . to be_truthy
8
7
expect ( RailsDataMigrations ::Migrator . get_all_versions ) . to be_blank
9
8
end
10
9
You can’t perform that action at this time.
0 commit comments