grafana/pkg/services/sqlstore/migrations/temp_user.go
Dan Cech 24d4e50343 utf8mb4 encoding (#7959)
* use utf8mb4 character set for connections to mysql

* use utf8mb4 character set for tables, shorten varchar fields used in unique indexes

* migration type to update table character set

* update table character sets

* set charset for temp_user.status

* gofmt
2017-03-28 14:34:53 +02:00

48 lines
1.9 KiB
Go

package migrations
import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
func addTempUserMigrations(mg *Migrator) {
tempUserV1 := Table{
Name: "temp_user",
Columns: []*Column{
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "org_id", Type: DB_BigInt, Nullable: false},
{Name: "version", Type: DB_Int, Nullable: false},
{Name: "email", Type: DB_NVarchar, Length: 255},
{Name: "name", Type: DB_NVarchar, Length: 255, Nullable: true},
{Name: "role", Type: DB_NVarchar, Length: 20, Nullable: true},
{Name: "code", Type: DB_NVarchar, Length: 255},
{Name: "status", Type: DB_Varchar, Length: 20},
{Name: "invited_by_user_id", Type: DB_BigInt, Nullable: true},
{Name: "email_sent", Type: DB_Bool},
{Name: "email_sent_on", Type: DB_DateTime, Nullable: true},
{Name: "remote_addr", Type: DB_Varchar, Length: 255, Nullable: true},
{Name: "created", Type: DB_DateTime},
{Name: "updated", Type: DB_DateTime},
},
Indices: []*Index{
{Cols: []string{"email"}, Type: IndexType},
{Cols: []string{"org_id"}, Type: IndexType},
{Cols: []string{"code"}, Type: IndexType},
{Cols: []string{"status"}, Type: IndexType},
},
}
// addDropAllIndicesMigrations(mg, "v7", tempUserV1)
// mg.AddMigration("Drop old table tempUser v7", NewDropTableMigration("temp_user"))
// create table
mg.AddMigration("create temp user table v1-7", NewAddTableMigration(tempUserV1))
addTableIndicesMigrations(mg, "v1-7", tempUserV1)
mg.AddMigration("Update temp_user table charset", NewTableCharsetMigration("temp_user", []*Column{
{Name: "email", Type: DB_NVarchar, Length: 255},
{Name: "name", Type: DB_NVarchar, Length: 255, Nullable: true},
{Name: "role", Type: DB_NVarchar, Length: 20, Nullable: true},
{Name: "code", Type: DB_NVarchar, Length: 255},
{Name: "status", Type: DB_Varchar, Length: 20},
{Name: "remote_addr", Type: DB_Varchar, Length: 255, Nullable: true},
}))
}