Module: DatabaseConsistency::Writers::Autofix::Helpers::Migration

Included in:
MigrationBase
Defined in:
lib/database_consistency/writers/autofix/helpers/migration.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#migration_configuration(name) ⇒ Object



21
22
23
24
25
26
# File 'lib/database_consistency/writers/autofix/helpers/migration.rb', line 21

def migration_configuration(name)
  {
    migration_name: name.camelcase,
    migration_version: ActiveRecord::Migration.current_version
  }
end

#migration_path(name) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/database_consistency/writers/autofix/helpers/migration.rb', line 8

def migration_path(name)
  migration_context = ActiveRecord::Base.connection.migration_context

  last = migration_context.migrations.last
  version = ActiveRecord::Migration.next_migration_number(last&.version.to_i + 1)

  "db/migrate/#{version}_#{name.underscore}.rb"
end

#migration_path_pattern(name) ⇒ Object



17
18
19
# File 'lib/database_consistency/writers/autofix/helpers/migration.rb', line 17

def migration_path_pattern(name)
  "db/migrate/*_#{name.underscore}.rb"
end