Module: ViewData::PG::Controls::Table::CompositePrimaryKey

Defined in:
lib/view_data/pg/controls/table/composite_primary_key.rb

Class Method Summary collapse

Class Method Details

.create(drop: nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/view_data/pg/controls/table/composite_primary_key.rb', line 6

def self.create(drop: nil)
  session = Session.build

  if drop
    session.execute("DROP TABLE IF EXISTS #{name}")
  end

  session.execute("    CREATE TABLE \#{name} (\n      id_1 uuid NOT NULL,\n      id_2 uuid NOT NULL,\n\n      some_column text,\n\n      PRIMARY KEY(id_1, id_2)\n    )\n  SQL\n\n  session.close\nend\n")

.nameObject



27
28
29
# File 'lib/view_data/pg/controls/table/composite_primary_key.rb', line 27

def self.name
  'test_composite_primary_key'
end