grafana/pkg/services/sqlstore/migrations/quota_mig.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

33 lines
1.0 KiB
Go

package migrations
import (
. "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
)
func addQuotaMigration(mg *Migrator) {
var quotaV1 = Table{
Name: "quota",
Columns: []*Column{
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "org_id", Type: DB_BigInt, Nullable: true},
{Name: "user_id", Type: DB_BigInt, Nullable: true},
{Name: "target", Type: DB_NVarchar, Length: 190, Nullable: false},
{Name: "limit", Type: DB_BigInt, Nullable: false},
{Name: "created", Type: DB_DateTime, Nullable: false},
{Name: "updated", Type: DB_DateTime, Nullable: false},
},
Indices: []*Index{
{Cols: []string{"org_id", "user_id", "target"}, Type: UniqueIndex},
},
}
mg.AddMigration("create quota table v1", NewAddTableMigration(quotaV1))
//------- indexes ------------------
addTableIndicesMigrations(mg, "v1", quotaV1)
mg.AddMigration("Update quota table charset", NewTableCharsetMigration("quota", []*Column{
{Name: "target", Type: DB_NVarchar, Length: 190, Nullable: false},
}))
}