Role mapping: Add `group_mapping_uid` column to `user_role` table (#93810)

* add group_mapping_uid column to user_role table

* add group mapping UID to user role struct
pull/94331/head
Ieva 8 months ago committed by GitHub
parent 63bdbb67fc
commit d7aca7d0fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      pkg/services/accesscontrol/models.go
  2. 14
      pkg/services/sqlstore/migrations/accesscontrol/migrations.go

@ -173,10 +173,11 @@ type TeamRole struct {
}
type UserRole struct {
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
OrgID int64 `json:"orgId" xorm:"org_id"`
RoleID int64 `json:"roleId" xorm:"role_id"`
UserID int64 `json:"userId" xorm:"user_id"`
ID int64 `json:"id" xorm:"pk autoincr 'id'"`
OrgID int64 `json:"orgId" xorm:"org_id"`
RoleID int64 `json:"roleId" xorm:"role_id"`
UserID int64 `json:"userId" xorm:"user_id"`
GroupMappingUID string `json:"groupMappingUID" xorm:"group_mapping_uid"`
Created time.Time
}

@ -196,4 +196,18 @@ func AddMigration(mg *migrator.Migrator) {
Type: migrator.UniqueIndex,
Cols: []string{"role_id", "action", "scope"},
}))
mg.AddMigration("add group mapping UID column to user_role table", migrator.NewAddColumnMigration(userRoleV1, &migrator.Column{
Name: "group_mapping_uid", Type: migrator.DB_NVarchar, Length: 40, Default: "''", Nullable: true,
}))
mg.AddMigration("add user_role org ID, user ID, role ID, group mapping UID index", migrator.NewAddIndexMigration(userRoleV1, &migrator.Index{
Type: migrator.UniqueIndex,
Cols: []string{"org_id", "user_id", "role_id", "group_mapping_uid"},
}))
mg.AddMigration("remove user_role org ID, user ID, role ID index", migrator.NewDropIndexMigration(userRoleV1, &migrator.Index{
Type: migrator.UniqueIndex,
Cols: []string{"org_id", "user_id", "role_id"},
}))
}

Loading…
Cancel
Save