Module: Scenic::Statements

Defined in:
lib/scenic_oracle_pk.rb

Instance Method Summary collapse

Instance Method Details

#create_pk_for_view(name, key = 'id') ⇒ Object



11
12
13
14
15
16
# File 'lib/scenic_oracle_pk.rb', line 11

def create_pk_for_view(name, key = 'id')
  key_name = [name.to_s.split('.').last, key.to_s, 'pk'].join('_')
  execute <<-SQL
  ALTER VIEW #{quote_table_name(name)} ADD CONSTRAINT #{key_name} PRIMARY KEY (#{key}) DISABLE
  SQL
end

#remove_pk_for_view(name, key = 'id') ⇒ Object



18
19
20
21
22
23
# File 'lib/scenic_oracle_pk.rb', line 18

def remove_pk_for_view(name, key = 'id')
  key_name = [name.to_s.split('.').last, key.to_s, 'pk'].join('_')
  execute <<-SQL
  ALTER VIEW #{quote_table_name(name)} DROP CONSTRAINT #{key_name} PRIMARY KEY (#{key}) DISABLE
  SQL
end