Class: DeclareSchema::SchemaChange::PrimaryKeyChange

Inherits:
Base
  • Object
show all
Defined in:
lib/declare_schema/schema_change/primary_key_change.rb

Instance Method Summary collapse

Methods inherited from Base

#down, format_options, #up

Constructor Details

#initialize(table_name, old_column_names, new_column_names) ⇒ PrimaryKeyChange

rubocop:disable Lint/MissingSuper



8
9
10
11
12
# File 'lib/declare_schema/schema_change/primary_key_change.rb', line 8

def initialize(table_name, old_column_names, new_column_names) # rubocop:disable Lint/MissingSuper
  @table_name = table_name
  @old_column_names = old_column_names.presence
  @new_column_names = new_column_names.presence
end

Instance Method Details

#down_commandObject



18
19
20
# File 'lib/declare_schema/schema_change/primary_key_change.rb', line 18

def down_command
  alter_primary_key(@new_column_names, @old_column_names)
end

#up_commandObject



14
15
16
# File 'lib/declare_schema/schema_change/primary_key_change.rb', line 14

def up_command
  alter_primary_key(@old_column_names, @new_column_names)
end