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(<<~SQL)
    CREATE TABLE #{name} (
      id_1 uuid NOT NULL,
      id_2 uuid NOT NULL,

      some_column text,

      PRIMARY KEY(id_1, id_2)
    )
  SQL

  session.close
end

.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