-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMigration.go
63 lines (47 loc) · 1.15 KB
/
Migration.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
package exodus
type MigrationCommand string
// Migration does x.
type Migration interface {
Up(migrate *MigrationPayload)
Down(migrate *MigrationPayload)
}
type operation int
const (
UNKNOWN_OPERATION operation = iota
CREATE_TABLE
DROP_TABLE
RENAME_TABLE
RAW_SQL
)
type MigrationOperation struct {
operation operation
payload interface{}
table string
}
func (o MigrationOperation) Operation() operation {
return o.operation
}
func (o MigrationOperation) Payload() interface{} {
return o.payload
}
func (o MigrationOperation) Table() string {
return o.table
}
type MigrationPayload struct {
ops []*MigrationOperation
}
func (p *MigrationPayload) Operations() []*MigrationOperation {
return p.ops
}
/*
needs more than this, as the different dialects need to be able to inspect the column
and do stuff with it.
So something like:
operation:
create table - will need to contain a payload of columns to create - column.Definition
drop table - easy - pass in string and turn into `drop table string;`
rename table - easy - pass in strings and turn into `rename table string1 to string2`
alter table
alter table add column
alter table drop column
*/