Class: PGTrunk::Operations::Sequences::ChangeSequence
- Inherits:
-
Base
show all
- Defined in:
- lib/pg_trunk/operations/sequences/change_sequence.rb
Instance Method Summary
collapse
#quote
#dump, #to_a, #to_opts, #to_ruby
#invert!, #irreversible!
#error_messages
#attributes, #initialize
Instance Method Details
#invert ⇒ Object
73
74
75
76
77
78
79
80
81
|
# File 'lib/pg_trunk/operations/sequences/change_sequence.rb', line 73
def invert
irreversible!("if_exists: true") if if_exists
undefined = inversion.select { |_, v| v.nil? }.keys.join(", ").presence
raise IrreversibleMigration.new(self, nil, <<~MSG.squish) if undefined
Undefined values to revert #{undefined}.
MSG
self.class.new(name: name, **inversion) if inversion.any?
end
|
#owned_by(table, column, from: nil) ⇒ Object
63
64
65
66
67
|
# File 'lib/pg_trunk/operations/sequences/change_sequence.rb', line 63
def owned_by(table, column, from: nil)
self.table = table
self.column = column
self.from_table, self.from_column = Array(from)
end
|
#to_sql(_version) ⇒ Object
69
70
71
|
# File 'lib/pg_trunk/operations/sequences/change_sequence.rb', line 69
def to_sql(_version)
[*alter_sequence, *].join(" ")
end
|