/
migrate_stubs.go
129 lines (109 loc) · 3.03 KB
/
migrate_stubs.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package console
type MysqlStubs struct {
}
// CreateUp Create up migration content.
func (receiver MysqlStubs) CreateUp() string {
return `CREATE TABLE DummyTable (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
created_at datetime(3) NOT NULL,
updated_at datetime(3) NOT NULL,
PRIMARY KEY (id),
KEY idx_DummyTable_created_at (created_at),
KEY idx_DummyTable_updated_at (updated_at)
) ENGINE = InnoDB DEFAULT CHARSET = DummyDatabaseCharset;
`
}
// CreateDown Create down migration content.
func (receiver MysqlStubs) CreateDown() string {
return `DROP TABLE IF EXISTS DummyTable;
`
}
// UpdateUp Update up migration content.
func (receiver MysqlStubs) UpdateUp() string {
return `ALTER TABLE DummyTable ADD column varchar(255) COMMENT '';
`
}
// UpdateDown Update down migration content.
func (receiver MysqlStubs) UpdateDown() string {
return `ALTER TABLE DummyTable DROP COLUMN column;
`
}
type PostgresqlStubs struct {
}
// CreateUp Create up migration content.
func (receiver PostgresqlStubs) CreateUp() string {
return `CREATE TABLE DummyTable (
id SERIAL PRIMARY KEY NOT NULL,
created_at timestamp NOT NULL,
updated_at timestamp NOT NULL
);
`
}
// CreateDown Create down migration content.
func (receiver PostgresqlStubs) CreateDown() string {
return `DROP TABLE IF EXISTS DummyTable;
`
}
// UpdateUp Update up migration content.
func (receiver PostgresqlStubs) UpdateUp() string {
return `ALTER TABLE DummyTable ADD column varchar(255) NOT NULL;
`
}
// UpdateDown Update down migration content.
func (receiver PostgresqlStubs) UpdateDown() string {
return `ALTER TABLE DummyTable DROP COLUMN column;
`
}
type SqliteStubs struct {
}
// CreateUp Create up migration content.
func (receiver SqliteStubs) CreateUp() string {
return `CREATE TABLE DummyTable (
id integer PRIMARY KEY AUTOINCREMENT NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
`
}
// CreateDown Create down migration content.
func (receiver SqliteStubs) CreateDown() string {
return `DROP TABLE IF EXISTS DummyTable;
`
}
// UpdateUp Update up migration content.
func (receiver SqliteStubs) UpdateUp() string {
return `ALTER TABLE DummyTable ADD column text;
`
}
// UpdateDown Update down migration content.
func (receiver SqliteStubs) UpdateDown() string {
return `ALTER TABLE DummyTable DROP COLUMN column;
`
}
type SqlserverStubs struct {
}
// CreateUp Create up migration content.
func (receiver SqlserverStubs) CreateUp() string {
return `CREATE TABLE DummyTable (
id bigint NOT NULL IDENTITY(1,1),
created_at datetime NOT NULL,
updated_at datetime NOT NULL,
PRIMARY KEY (id)
);
`
}
// CreateDown Create down migration content.
func (receiver SqlserverStubs) CreateDown() string {
return `DROP TABLE IF EXISTS DummyTable;
`
}
// UpdateUp Update up migration content.
func (receiver SqlserverStubs) UpdateUp() string {
return `ALTER TABLE DummyTable ADD column varchar(255);
`
}
// UpdateDown Update down migration content.
func (receiver SqlserverStubs) UpdateDown() string {
return `ALTER TABLE DummyTable DROP COLUMN column;
`
}