adding more columns for account table migration

This commit is contained in:
Torkel Ödegaard 2015-01-18 20:09:30 +01:00
parent a64a38d7dd
commit 7d70ffe201
2 changed files with 25 additions and 9 deletions

View File

@ -23,24 +23,40 @@ func AddMigrations(mg *Migrator) {
mg.AddMigration("create account table", new(RawSqlMigration).
Sqlite(`
CREATE TABLE account (
id INTEGER PRIMARY KEY AUTOINCREMENT,
login TEXT NOT NULL,
email TEXT NOT NULL
id INTEGER PRIMARY KEY AUTOINCREMENT,
login TEXT NOT NULL,
email TEXT NOT NULL,
name TEXT NULL,
password TEXT NULL,
salt TEXT NULL,
company TEXT NULL,
using_account_id INTEGER NULL,
is_admin INTEGER NOT NULL,
created INTEGER NOT NULL,
updated INTEGER NOT NULL
)
`).
Mysql(`
CREATE TABLE account (
id BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id),
login VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL
id BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id),
login VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
name VARCHAR(255) NULL,
password VARCHAR(50) NULL,
salt VARCHAR(50) NULL,
company VARCHAR(255) NULL,
using_account_id BIGINT NULL,
is_admin BOOL NOT NULL,
created DATETIME NOT NULL,
update DATETIME NOT NULL
)
`))
// ------------------------------
mg.AddMigration("add index UIX_account.login", new(AddIndexMigration).
Name("UIX_account_login").Table("account").Columns("login"))
// ------------------------------
mg.AddMigration("add column", new(AddColumnMigration).
Table("account").Column("name").Type(DB_TYPE_STRING).Length(255))
// mg.AddMigration("add column", new(AddColumnMigration).
// Table("account").Column("name").Type(DB_TYPE_STRING).Length(255))
}
type MigrationLog struct {

View File

@ -35,7 +35,7 @@ func TestMigrations(t *testing.T) {
log.NewLogger(0, "console", `{"level": 0}`)
testDBs := [][]string{
[]string{"mysql", "grafana:password@tcp(localhost:3306)/grafana_tests?charset=utf8"},
//[]string{"mysql", "grafana:password@tcp(localhost:3306)/grafana_tests?charset=utf8"},
[]string{"sqlite3", ":memory:"},
}