Class: Liquigen::Handlers::CreateTable
- Inherits:
-
Base
- Object
- Base
- Liquigen::Handlers::CreateTable
show all
- Defined in:
- lib/liquigen/handlers/create_table.rb
Instance Attribute Summary
Attributes inherited from Base
#id, #props, #sets, #table
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #process
Instance Method Details
#action_name ⇒ Object
5
6
7
|
# File 'lib/liquigen/handlers/create_table.rb', line 5
def action_name
'CreateTable'
end
|
#build_column(name_and_type) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/liquigen/handlers/create_table.rb', line 15
def build_column(name_and_type)
kv = name_and_type.split(':')
column = Liquigen::Column.new(name: kv[0], type: kv[1])
unless constraints?
column.constraints = nil
return column
end
if column.name == 'id'
column.auto_increment = true
column.constraints.primary_key = true
else
column.constraints.nullable = false
end
column
end
|
#build_one_changeset(set) ⇒ Object
9
10
11
12
13
|
# File 'lib/liquigen/handlers/create_table.rb', line 9
def build_one_changeset(set)
change = Liquigen::CreateTable.new(table)
set.changes << change
props.each { |kv| change.columns << build_column(kv) }
end
|
#constraints? ⇒ Boolean
34
35
36
|
# File 'lib/liquigen/handlers/create_table.rb', line 34
def constraints?
true
end
|