Class: PGTrunk::Operations::Sequences::DropSequence

Inherits:
Base show all
Defined in:
lib/pg_trunk/operations/sequences/drop_sequence.rb

Instance Method Summary collapse

Methods inherited from Base

#owned_by

Methods included from PGTrunk::Operation::SQLHelpers

#quote

Methods included from PGTrunk::Operation::RubyHelpers

#dump, #to_a, #to_opts, #to_ruby

Methods included from PGTrunk::Operation::Inversion

#invert!, #irreversible!

Methods included from PGTrunk::Operation::Validations

#error_messages

Methods included from PGTrunk::Operation::Attributes

#attributes, #initialize

Instance Method Details

#invertObject



76
77
78
79
80
# File 'lib/pg_trunk/operations/sequences/drop_sequence.rb', line 76

def invert
  irreversible!("if_exists: true") if if_exists
  irreversible!("force: :cascade") if force == :cascade
  CreateSequence.new(**to_h.except(:if_exists, :force))
end

#to_sql(_version) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/pg_trunk/operations/sequences/drop_sequence.rb', line 68

def to_sql(_version)
  sql = "DROP SEQUENCE"
  sql << " IF EXISTS" if if_exists
  sql << " #{name.to_sql}"
  sql << " CASCADE" if force == :cascade
  sql << ";"
end