diff --git a/pkg/services/team/teamimpl/store.go b/pkg/services/team/teamimpl/store.go index 7c422d8abf5..8f3db689fd3 100644 --- a/pkg/services/team/teamimpl/store.go +++ b/pkg/services/team/teamimpl/store.go @@ -11,7 +11,6 @@ import ( "github.com/grafana/grafana/pkg/infra/db" ac "github.com/grafana/grafana/pkg/services/accesscontrol" "github.com/grafana/grafana/pkg/services/dashboards/dashboardaccess" - "github.com/grafana/grafana/pkg/services/sqlstore/migrator" "github.com/grafana/grafana/pkg/services/team" "github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/util" @@ -567,25 +566,3 @@ func (ss *xormStore) getTeamMembers(ctx context.Context, query *team.GetTeamMemb func (ss *xormStore) RegisterDelete(query string) { ss.deletes = append(ss.deletes, query) } - -// This is just to ensure that all teams have a valid uid. -// To protect against upgrade / downgrade we need to run this for a couple of releases. -// FIXME: Remove this migration and make uid field required https://github.com/grafana/identity-access-team/issues/552 -func (ss *xormStore) uidMigration() error { - return ss.db.WithDbSession(context.Background(), func(sess *db.Session) error { - switch ss.db.GetDBType() { - case migrator.SQLite: - _, err := sess.Exec("UPDATE team SET uid=printf('t%09d',id) WHERE uid IS NULL;") - return err - case migrator.Postgres: - _, err := sess.Exec("UPDATE team SET uid='t' || lpad('' || id::text,9,'0') WHERE uid IS NULL;") - return err - case migrator.MySQL: - _, err := sess.Exec("UPDATE team SET uid=concat('t',lpad(id,9,'0')) WHERE uid IS NULL;") - return err - default: - // this branch should be unreachable - return nil - } - }) -} diff --git a/pkg/services/team/teamimpl/team.go b/pkg/services/team/teamimpl/team.go index 1eb8e7c1b2d..e7c9537b751 100644 --- a/pkg/services/team/teamimpl/team.go +++ b/pkg/services/team/teamimpl/team.go @@ -18,11 +18,6 @@ type Service struct { } func ProvideService(db db.DB, cfg *setting.Cfg, tracer tracing.Tracer) (team.Service, error) { - store := &xormStore{db: db, cfg: cfg, deletes: []string{}} - - if err := store.uidMigration(); err != nil { - return nil, err - } return &Service{ store: &xormStore{db: db, cfg: cfg, deletes: []string{}}, tracer: tracer, diff --git a/pkg/services/user/userimpl/user.go b/pkg/services/user/userimpl/user.go index 3e340736498..db911d4c408 100644 --- a/pkg/services/user/userimpl/user.go +++ b/pkg/services/user/userimpl/user.go @@ -17,7 +17,6 @@ import ( "github.com/grafana/grafana/pkg/services/org" "github.com/grafana/grafana/pkg/services/quota" "github.com/grafana/grafana/pkg/services/serviceaccounts" - "github.com/grafana/grafana/pkg/services/sqlstore/migrator" "github.com/grafana/grafana/pkg/services/supportbundles" "github.com/grafana/grafana/pkg/services/team" "github.com/grafana/grafana/pkg/services/user" @@ -65,10 +64,6 @@ func ProvideService( return s, err } - if err := s.uidMigration(db); err != nil { - return nil, err - } - bundleRegistry.RegisterSupportItemCollector(s.supportBundleCollector()) return s, nil } @@ -529,25 +524,3 @@ func readQuotaConfig(cfg *setting.Cfg) (*quota.Map, error) { limits.Set(globalQuotaTag, cfg.Quota.Global.User) return limits, nil } - -// This is just to ensure that all users have a valid uid. -// To protect against upgrade / downgrade we need to run this for a couple of releases. -// FIXME: Remove this migration and make uid field required https://github.com/grafana/identity-access-team/issues/552 -func (s *Service) uidMigration(store db.DB) error { - return store.WithDbSession(context.Background(), func(sess *db.Session) error { - switch store.GetDBType() { - case migrator.SQLite: - _, err := sess.Exec("UPDATE user SET uid=printf('u%09d',id) WHERE uid IS NULL;") - return err - case migrator.Postgres: - _, err := sess.Exec("UPDATE `user` SET uid='u' || lpad('' || id::text,9,'0') WHERE uid IS NULL;") - return err - case migrator.MySQL: - _, err := sess.Exec("UPDATE user SET uid=concat('u',lpad(id,9,'0')) WHERE uid IS NULL;") - return err - default: - // this branch should be unreachable - return nil - } - }) -}