Class: Torque::PostgreSQL::VersionedCommands::CommandMigration
- Inherits:
-
Struct
- Object
- Struct
- Torque::PostgreSQL::VersionedCommands::CommandMigration
- Defined in:
- lib/torque/postgresql/versioned_commands/command_migration.rb,
sig/torque/postgresql/versioned_commands/command_migration.rbs
Instance Method Summary collapse
-
#disable_ddl_transaction ⇒ false
There is no way to setup this, so it is always false.
-
#down ⇒ Object
Find the previous command and executes it.
-
#drop ⇒ Object
Drops the type created.
- #execute ⇒ Object
- #filename ⇒ String
- #filename= ⇒ String
-
#initialize(filename, *args) ⇒ CommandMigration
constructor
A new instance of CommandMigration.
-
#migrate(direction) ⇒ Object
Down is more complicated, then this just starts separating the logic.
-
#name ⇒ String
Rails uses this to avoid duplicate migrations.
- #object_name ⇒ String
- #object_name= ⇒ String
- #op ⇒ String
- #op= ⇒ String
- #op_version ⇒ Integer
- #op_version= ⇒ Integer
- #scope ⇒ String?
- #scope= ⇒ String?
- #type ⇒ String
- #type= ⇒ String
-
#up ⇒ Object
Simply executes the underlying command.
- #version ⇒ Integer
- #version= ⇒ Integer
Constructor Details
#initialize(filename, *args) ⇒ CommandMigration
Returns a new instance of CommandMigration.
68 69 70 71 |
# File 'lib/torque/postgresql/versioned_commands/command_migration.rb', line 68 def initialize(filename, *args) super(File.(filename), *args) @migration = nil end |
Instance Method Details
#disable_ddl_transaction ⇒ false
There is no way to setup this, so it is always false
79 80 81 |
# File 'lib/torque/postgresql/versioned_commands/command_migration.rb', line 79 def disable_ddl_transaction false end |
#down ⇒ Object
Find the previous command and executes it
101 102 103 104 105 106 |
# File 'lib/torque/postgresql/versioned_commands/command_migration.rb', line 101 def down return drop if op_version == 1 dirs = @migration.pool.migrations_paths version = op_version - (op == 'remove' ? 0 : 1) execute VersionedCommands.fetch_command(dirs, type, object_name, version) end |
#drop ⇒ Object
Drops the type created
109 110 111 112 113 |
# File 'lib/torque/postgresql/versioned_commands/command_migration.rb', line 109 def drop method_name = :"drop_#{type}" return send(method_name) if VersionedCommands.valid_type?(type) raise ArgumentError, "Unknown versioned command type: #{type}" end |
#execute ⇒ Object
36 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 36
def execute: (String command) -> untyped
|
#filename ⇒ String
21 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 21
def filename: () -> String
|
#filename= ⇒ String
22 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 22
def filename=: (String value) -> String
|
#migrate(direction) ⇒ Object
Down is more complicated, then this just starts separating the logic
84 85 86 87 88 89 90 91 |
# File 'lib/torque/postgresql/versioned_commands/command_migration.rb', line 84 def migrate(direction) @migration = ActiveRecord::Migration.allocate @migration.extend(Migration) @migration.send(:initialize, name, version, self) @migration.migrate(direction) ensure @migration = nil end |
#name ⇒ String
Rails uses this to avoid duplicate migrations
74 75 76 |
# File 'lib/torque/postgresql/versioned_commands/command_migration.rb', line 74 def name "#{op}_#{type}_#{object_name}_v#{op_version}" end |
#object_name ⇒ String
29 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 29
def object_name: () -> String
|
#object_name= ⇒ String
30 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 30
def object_name=: (String value) -> String
|
#op ⇒ String
25 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 25
def op: () -> String
|
#op= ⇒ String
26 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 26
def op=: (String value) -> String
|
#op_version ⇒ Integer
31 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 31
def op_version: () -> Integer
|
#op_version= ⇒ Integer
32 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 32
def op_version=: (Integer value) -> Integer
|
#scope ⇒ String?
33 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 33
def scope: () -> String?
|
#scope= ⇒ String?
34 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 34
def scope=: (String? value) -> String?
|
#type ⇒ String
27 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 27
def type: () -> String
|
#type= ⇒ String
28 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 28
def type=: (String value) -> String
|
#up ⇒ Object
Simply executes the underlying command
94 95 96 97 98 |
# File 'lib/torque/postgresql/versioned_commands/command_migration.rb', line 94 def up content = File.read(filename) VersionedCommands.validate!(type, content, object_name) execute content end |
#version ⇒ Integer
23 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 23
def version: () -> Integer
|
#version= ⇒ Integer
24 |
# File 'sig/torque/postgresql/versioned_commands/command_migration.rbs', line 24
def version=: (Integer value) -> Integer
|