Module: SQL::Postgres

Defined in:
lib/dm-migrations/sql/postgres.rb

Defined Under Namespace

Classes: Column, Table

Instance Method Summary collapse

Instance Method Details

#property_schema_statement(connection, schema) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dm-migrations/sql/postgres.rb', line 22

def property_schema_statement(connection, schema)
  if supports_serial? && schema[:serial]
    statement = "#{schema[:quote_column_name]} SERIAL PRIMARY KEY"
  else
    statement = super
    if schema.has_key?(:sequence_name)
      statement << " DEFAULT nextval('#{schema[:sequence_name]}') NOT NULL"
    end
    statement
  end
  statement
end

#recreate_databaseObject



12
13
14
15
16
# File 'lib/dm-migrations/sql/postgres.rb', line 12

def recreate_database
  execute 'DROP SCHEMA IF EXISTS test CASCADE'
  execute 'CREATE SCHEMA test'
  execute 'SET search_path TO test'
end

#supports_schema_transactions?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/dm-migrations/sql/postgres.rb', line 4

def supports_schema_transactions?
  true
end

#supports_serial?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/dm-migrations/sql/postgres.rb', line 18

def supports_serial?
  true
end

#table(table_name) ⇒ Object



8
9
10
# File 'lib/dm-migrations/sql/postgres.rb', line 8

def table(table_name)
  SQL::Postgres::Table.new(self, table_name)
end

#table_optionsObject



35
36
37
# File 'lib/dm-migrations/sql/postgres.rb', line 35

def table_options
  ''
end