add uid to team table (#66920)

* add uid to team table

* concat

* add prefix to transition uids

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Dan Cech
2023-05-09 13:03:28 -04:00
committed by GitHub
co-authored by Ryan McKinley
parent 10109eaf00
commit 7572988305
3 changed files with 46 additions and 11 deletions
@@ -24,6 +24,19 @@ func addTeamMigrations(mg *Migrator) {
mg.AddMigration("add index team.org_id", NewAddIndexMigration(teamV1, teamV1.Indices[0]))
mg.AddMigration("add unique index team_org_id_name", NewAddIndexMigration(teamV1, teamV1.Indices[1]))
mg.AddMigration("Add column uid in team", NewAddColumnMigration(teamV1, &Column{
Name: "uid", Type: DB_NVarchar, Length: 40, Nullable: true,
}))
mg.AddMigration("Update uid column values in team", NewRawSQLMigration("").
SQLite("UPDATE team SET uid=printf('t%09d',id) WHERE uid IS NULL;").
Postgres("UPDATE team SET uid='t' || lpad('' || id::text,9,'0') WHERE uid IS NULL;").
Mysql("UPDATE team SET uid=concat('t',lpad(id,9,'0')) WHERE uid IS NULL;"))
mg.AddMigration("Add unique index team_org_id_uid", NewAddIndexMigration(teamV1, &Index{
Cols: []string{"org_id", "uid"}, Type: UniqueIndex,
}))
teamMemberV1 := Table{
Name: "team_member",
Columns: []*Column{