Module: PostgreSQLAdapterExtensions::CommandRecorder
- Defined in:
- lib/postgresql_adapter_extensions/command_recorder.rb
Overview
Module that extends ActiveRecord’s CommandRecorder to handle sequence-related commands.
This module is designed to work with reversible migrations in ActiveRecord, specifically to manage PostgreSQL sequence operations. The methods capture forward migration commands for sequences and generate their inverse using simple metaprogramming.
This will create a sequence, and during rollback, it will drop the sequence.
Instance Method Summary collapse
-
#alter_sequence(*args, &block) ⇒ void
Records the alteration of a PostgreSQL sequence during a migration.
-
#create_sequence(*args, &block) ⇒ void
Records the creation of a PostgreSQL sequence during a migration.
-
#drop_sequence(*args, &block) ⇒ void
Records the dropping of a PostgreSQL sequence during a migration.
-
#rename_sequence(*args) ⇒ void
Records the renaming of a PostgreSQL sequence during a migration.
Instance Method Details
#alter_sequence(*args, &block) ⇒ void
This method returns an undefined value.
Records the alteration of a PostgreSQL sequence during a migration.
This method is invoked when altering a sequence in the database. The corresponding inverse operation is not possible, so it will raise an error during rollback.
58 59 60 |
# File 'lib/postgresql_adapter_extensions/command_recorder.rb', line 58 def alter_sequence(*args, &block) record(:alter_sequence, args, &block) end |
#create_sequence(*args, &block) ⇒ void
This method returns an undefined value.
Records the creation of a PostgreSQL sequence during a migration.
This method is invoked when creating a sequence in the database. The corresponding inverse operation will be to drop the sequence during rollback.
40 41 42 |
# File 'lib/postgresql_adapter_extensions/command_recorder.rb', line 40 def create_sequence(*args, &block) record(:create_sequence, args, &block) end |
#drop_sequence(*args, &block) ⇒ void
This method returns an undefined value.
Records the dropping of a PostgreSQL sequence during a migration.
This method is invoked when dropping a sequence from the database. The corresponding inverse operation is not possible, so it will raise an error during rollback.
76 77 78 |
# File 'lib/postgresql_adapter_extensions/command_recorder.rb', line 76 def drop_sequence(*args, &block) record(:drop_sequence, args, &block) end |
#rename_sequence(*args) ⇒ void
This method returns an undefined value.
Records the renaming of a PostgreSQL sequence during a migration.
This method is invoked when renaming a sequence in the database. The corresponding inverse operation will be to rename the sequence back to its original name during rollback.
93 94 95 |
# File 'lib/postgresql_adapter_extensions/command_recorder.rb', line 93 def rename_sequence(*args) record(:rename_sequence, args) end |