Module: Torque::PostgreSQL::Migration::CommandRecorder
- Defined in:
- lib/torque/postgresql/migration/command_recorder.rb
Instance Method Summary collapse
-
#add_composite_column(*args, &block) ⇒ Object
Records a column being added to a composite type.
-
#change_composite_column(*args, &block) ⇒ Object
Records the type of a column being changed, which cannot be inverted because the previous type is unknown.
-
#change_composite_type(*args, &block) ⇒ Object
Records changes to a composite type, which cannot be inverted for the same reason as
change_table. -
#create_composite_type(*args, &block) ⇒ Object
Records the creation of a composite type.
-
#create_schema(*args, &block) ⇒ Object
Records the creation of a schema.
-
#invert_add_composite_column(args) ⇒ Object
Inverts a column being added to a composite type.
-
#invert_create_composite_type(args) ⇒ Object
Inverts the creation of a composite type.
-
#invert_create_schema(args) ⇒ Object
Inverts the creation of a schema.
-
#invert_remove_composite_column(args) ⇒ Object
Inverts a column being removed from a composite type, which is only possible when its type was informed.
-
#invert_rename_composite_column(args) ⇒ Object
Inverts a column of a composite type being renamed.
-
#invert_rename_type(args) ⇒ Object
Inverts the type rename operation.
-
#invert_sync_inheritance_features(args) ⇒ Object
Inverts the spread of features by running it again while pruning, so the children converge back to whatever the parent looks like.
-
#remove_composite_column(*args, &block) ⇒ Object
Records a column being removed from a composite type.
-
#rename_composite_column(*args, &block) ⇒ Object
Records a column of a composite type being renamed.
-
#rename_type(*args, &block) ⇒ Object
Records the rename operation for types.
-
#sync_inheritance_features(*args, &block) ⇒ Object
Records the spread of features into inherited tables.
Instance Method Details
#add_composite_column(*args, &block) ⇒ Object
Records a column being added to a composite type
36 37 38 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 36 def add_composite_column(*args, &block) record(:add_composite_column, args, &block) end |
#change_composite_column(*args, &block) ⇒ Object
Records the type of a column being changed, which cannot be inverted because the previous type is unknown
62 63 64 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 62 def change_composite_column(*args, &block) record(:change_composite_column, args, &block) end |
#change_composite_type(*args, &block) ⇒ Object
Records changes to a composite type, which cannot be inverted for the
same reason as change_table
31 32 33 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 31 def change_composite_type(*args, &block) record(:change_composite_type, args, &block) end |
#create_composite_type(*args, &block) ⇒ Object
Records the creation of a composite type
19 20 21 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 19 def create_composite_type(*args, &block) record(:create_composite_type, args, &block) end |
#create_schema(*args, &block) ⇒ Object
Records the creation of a schema
95 96 97 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 95 def create_schema(*args, &block) record(:create_schema, args, &block) end |
#invert_add_composite_column(args) ⇒ Object
Inverts a column being added to a composite type
41 42 43 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 41 def invert_add_composite_column(args) [:remove_composite_column, args] end |
#invert_create_composite_type(args) ⇒ Object
Inverts the creation of a composite type
24 25 26 27 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 24 def invert_create_composite_type(args) = args.second.try(:slice, :schema) || {} [:drop_type, [args.first, ]] end |
#invert_create_schema(args) ⇒ Object
Inverts the creation of a schema
100 101 102 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 100 def invert_create_schema(args) [:drop_schema, [args.first]] end |
#invert_remove_composite_column(args) ⇒ Object
Inverts a column being removed from a composite type, which is only possible when its type was informed
52 53 54 55 56 57 58 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 52 def invert_remove_composite_column(args) raise ActiveRecord::IrreversibleMigration, <<~MSG.squish if args.third.nil? remove_composite_column is only reversible if given a type. MSG [:add_composite_column, args] end |
#invert_rename_composite_column(args) ⇒ Object
Inverts a column of a composite type being renamed
72 73 74 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 72 def invert_rename_composite_column(args) [:rename_composite_column, [args.first, args.third, args.second, *args[3..]]] end |
#invert_rename_type(args) ⇒ Object
Inverts the type rename operation
14 15 16 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 14 def invert_rename_type(args) [:rename_type, args.reverse] end |
#invert_sync_inheritance_features(args) ⇒ Object
Inverts the spread of features by running it again while pruning, so the children converge back to whatever the parent looks like
89 90 91 92 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 89 def invert_sync_inheritance_features(args) = args..merge(prune: true) [:sync_inheritance_features, [*args, Hash.ruby2_keywords_hash()]] end |
#remove_composite_column(*args, &block) ⇒ Object
Records a column being removed from a composite type
46 47 48 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 46 def remove_composite_column(*args, &block) record(:remove_composite_column, args, &block) end |
#rename_composite_column(*args, &block) ⇒ Object
Records a column of a composite type being renamed
67 68 69 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 67 def rename_composite_column(*args, &block) record(:rename_composite_column, args, &block) end |
#rename_type(*args, &block) ⇒ Object
Records the rename operation for types
9 10 11 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 9 def rename_type(*args, &block) record(:rename_type, args, &block) end |
#sync_inheritance_features(*args, &block) ⇒ Object
Records the spread of features into inherited tables. While reverting, the pruning form goes to the front of the list, which is played back reversed, so the children are only pruned once everything else the migration did to their parents has been undone
80 81 82 83 84 |
# File 'lib/torque/postgresql/migration/command_recorder.rb', line 80 def sync_inheritance_features(*args, &block) return record(:sync_inheritance_features, args, &block) unless reverting commands.unshift(inverse_of(:sync_inheritance_features, args, &block)) end |