grafana/pkg/services/sqlstore/migrations/short_url_mig.go
Arve Knudsen 676d393ec9
Chore: Fix issues reported by staticcheck; enable stylecheck linter (#28866)
* Chore: Fix issues reported by staticcheck

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Apply suggestions from code review

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
2020-11-05 15:37:11 +01:00

28 lines
921 B
Go
Executable File

package migrations
import (
. "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
)
func addShortURLMigrations(mg *Migrator) {
shortURLV1 := Table{
Name: "short_url",
Columns: []*Column{
{Name: "id", Type: DB_BigInt, Nullable: false, IsPrimaryKey: true, IsAutoIncrement: true},
{Name: "org_id", Type: DB_BigInt, Nullable: false},
{Name: "uid", Type: DB_NVarchar, Length: 40, Nullable: false},
{Name: "path", Type: DB_Text, Nullable: false},
{Name: "created_by", Type: DB_Int, Nullable: false},
{Name: "created_at", Type: DB_Int, Nullable: false},
{Name: "last_seen_at", Type: DB_Int, Nullable: true},
},
Indices: []*Index{
{Cols: []string{"org_id", "uid"}, Type: UniqueIndex},
},
}
mg.AddMigration("create short_url table v1", NewAddTableMigration(shortURLV1))
mg.AddMigration("add index short_url.org_id-uid", NewAddIndexMigration(shortURLV1, shortURLV1.Indices[0]))
}