blob: 8d23ed21566aecc01a8a65ac84f92d84de38084a (
plain)
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
|
package database
import "database/sql"
// allMigrations is the list of migrations to perform to get an up to date database
// Order is important. Add new migrations at the end of the list.
var allMigrations = []func(tx *sql.Tx) error{
func(tx *sql.Tx) (err error) {
sql := `
CREATE TABLE schema_version (
version INTEGER NOT NULL
);
CREATE TABLE users (
id INTEGER PRIMARY KEY,
username TEXT NOT NULL UNIQUE,
password TEXT,
email TEXT,
created_at DATE DEFAULT (datetime('now')),
last_login_at DATE DEFAULT NULL
);`
_, err = tx.Exec(sql)
return err
},
}
// This variable exists so that tests can override it
var migrations = allMigrations
|