quota_mig.go 888 B

12345678910111213141516171819202122232425262728
  1. package migrations
  2. import (
  3. . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
  4. )
  5. func addQuotaMigration(mg *Migrator) {
  6. var quotaV1 = Table{
  7. Name: "quota",
  8. Columns: []*Column{
  9. {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
  10. {Name: "org_id", Type: DB_BigInt, Nullable: true},
  11. {Name: "user_id", Type: DB_BigInt, Nullable: true},
  12. {Name: "target", Type: DB_NVarchar, Length: 255, Nullable: false},
  13. {Name: "limit", Type: DB_BigInt, Nullable: false},
  14. {Name: "created", Type: DB_DateTime, Nullable: false},
  15. {Name: "updated", Type: DB_DateTime, Nullable: false},
  16. },
  17. Indices: []*Index{
  18. {Cols: []string{"org_id", "user_id", "target"}, Type: UniqueIndex},
  19. },
  20. }
  21. mg.AddMigration("create quota table v1", NewAddTableMigration(quotaV1))
  22. //------- indexes ------------------
  23. addTableIndicesMigrations(mg, "v1", quotaV1)
  24. }