dashboard_acl.go 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. package migrations
  2. import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
  3. func addDashboardAclMigrations(mg *Migrator) {
  4. dashboardAclV1 := Table{
  5. Name: "dashboard_acl",
  6. Columns: []*Column{
  7. {Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
  8. {Name: "org_id", Type: DB_BigInt},
  9. {Name: "dashboard_id", Type: DB_BigInt},
  10. {Name: "user_id", Type: DB_BigInt, Nullable: true},
  11. {Name: "user_group_id", Type: DB_BigInt, Nullable: true},
  12. {Name: "permissions", Type: DB_SmallInt, Default: "4"},
  13. {Name: "created", Type: DB_DateTime, Nullable: false},
  14. {Name: "updated", Type: DB_DateTime, Nullable: false},
  15. },
  16. Indices: []*Index{
  17. {Cols: []string{"org_id"}},
  18. {Cols: []string{"dashboard_id", "user_id"}, Type: UniqueIndex},
  19. {Cols: []string{"dashboard_id", "user_group_id"}, Type: UniqueIndex},
  20. },
  21. }
  22. mg.AddMigration("create dashboard acl table", NewAddTableMigration(dashboardAclV1))
  23. //------- indexes ------------------
  24. mg.AddMigration("add unique index dashboard_acl_org_id", NewAddIndexMigration(dashboardAclV1, dashboardAclV1.Indices[0]))
  25. mg.AddMigration("add unique index dashboard_acl_dashboard_id_user_id", NewAddIndexMigration(dashboardAclV1, dashboardAclV1.Indices[1]))
  26. mg.AddMigration("add unique index dashboard_acl_dashboard_id_group_id", NewAddIndexMigration(dashboardAclV1, dashboardAclV1.Indices[2]))
  27. }