forked from GuiaBolso/darwin
-
Notifications
You must be signed in to change notification settings - Fork 3
/
mysql_dialect.go
45 lines (41 loc) · 1.47 KB
/
mysql_dialect.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
package darwin
// MySQLDialect a Dialect configured for MySQL
type MySQLDialect struct{}
// CreateTableSQL returns the SQL to create the schema table
func (m MySQLDialect) CreateTableSQL() string {
return `CREATE TABLE IF NOT EXISTS darwin_migrations
(
id INT auto_increment,
version INTEGER NOT NULL,
description VARCHAR(255) NOT NULL,
checksum VARCHAR(32) NOT NULL,
applied_at INT NOT NULL,
execution_time FLOAT NOT NULL,
UNIQUE (version),
PRIMARY KEY (id)
) ENGINE=InnoDB CHARACTER SET=utf8;`
}
// InsertSQL returns the SQL to insert a new migration in the schema table
func (m MySQLDialect) InsertSQL() string {
return `INSERT INTO darwin_migrations
(
version,
description,
checksum,
applied_at,
execution_time
)
VALUES (?, ?, ?, ?, ?);`
}
// AllSQL returns a SQL to get all entries in the table
func (m MySQLDialect) AllSQL() string {
return `SELECT
version,
description,
checksum,
applied_at,
execution_time
FROM
darwin_migrations
ORDER BY version ASC;`
}