forked from gobuffalo/fizz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
columns.go
66 lines (58 loc) · 1.25 KB
/
columns.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package fizz
var INT_ID_COL = Column{
Name: "id",
Primary: true,
ColType: "integer",
Options: Options{},
}
var UUID_ID_COL = Column{
Name: "id",
Primary: true,
ColType: "uuid",
Options: Options{},
}
var CREATED_COL = Column{Name: "created_at", ColType: "timestamp", Options: Options{}}
var UPDATED_COL = Column{Name: "updated_at", ColType: "timestamp", Options: Options{}}
type Column struct {
Name string
ColType string
Primary bool
Options map[string]interface{}
}
func (f fizzer) ChangeColumn(table, name, ctype string, options Options) {
t := Table{
Name: table,
Columns: []Column{
{Name: name, ColType: ctype, Options: options},
},
}
f.add(f.Bubbler.ChangeColumn(t))
}
func (f fizzer) AddColumn(table, name, ctype string, options Options) {
t := Table{
Name: table,
Columns: []Column{
{Name: name, ColType: ctype, Options: options},
},
}
f.add(f.Bubbler.AddColumn(t))
}
func (f fizzer) DropColumn(table, name string) {
t := Table{
Name: table,
Columns: []Column{
{Name: name},
},
}
f.add(f.Bubbler.DropColumn(t))
}
func (f fizzer) RenameColumn(table, old, new string) error {
t := Table{
Name: table,
Columns: []Column{
{Name: old},
{Name: new},
},
}
return f.add(f.Bubbler.RenameColumn(t))
}