Class: PGTrunk::Operations::Rules::DropRule
- Inherits:
-
Base
show all
- Defined in:
- lib/pg_trunk/operations/rules/drop_rule.rb
Instance Method Summary
collapse
Methods inherited from Base
#<=>
#quote
#dump, #to_a, #to_opts, #to_ruby
#invert!, #irreversible!
#error_messages
#attributes, #initialize
Instance Method Details
#invert ⇒ Object
88
89
90
91
92
|
# File 'lib/pg_trunk/operations/rules/drop_rule.rb', line 88
def invert
irreversible!("if_exists: true") if if_exists
irreversible!("force: :cascade") if force == :cascade
CreateRule.new(**to_h.except(:force))
end
|
#to_sql(_version) ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/pg_trunk/operations/rules/drop_rule.rb', line 80
def to_sql(_version)
sql = "DROP RULE"
sql << " IF EXISTS" if if_exists
sql << " #{name.name.inspect} ON #{table.to_sql}"
sql << " CASCADE" if force == :cascade
sql << ";"
end
|