mirror of
https://github.com/grafana/grafana.git
synced 2026-08-18 17:15:08 -05:00
APIKeys: add API key migration to ensure fk is null (#46285)
This commit is contained in:
@@ -182,7 +182,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
},
|
||||
},
|
||||
},
|
||||
Grants: []string{"Admin"},
|
||||
Grants: []string{string(models.ROLE_ADMIN)},
|
||||
}
|
||||
|
||||
orgReaderRole := ac.RoleRegistration{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package migrations
|
||||
|
||||
import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
import (
|
||||
. "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
)
|
||||
|
||||
func addApiKeyMigrations(mg *Migrator) {
|
||||
apiKeyV1 := Table{
|
||||
@@ -86,4 +88,7 @@ func addApiKeyMigrations(mg *Migrator) {
|
||||
mg.AddMigration("Add service account foreign key", NewAddColumnMigration(apiKeyV2, &Column{
|
||||
Name: "service_account_id", Type: DB_BigInt, Nullable: true,
|
||||
}))
|
||||
|
||||
mg.AddMigration("set service account foreign key to nil if 0", NewRawSQLMigration(
|
||||
"UPDATE api_key SET service_account_id = NULL WHERE service_account_id = 0;"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user