Skip to content

Commit 91bf7f7

Browse files
committed
UBERF-11178 Migrate datalake workspace id
Signed-off-by: Alexander Onnikov <[email protected]>
1 parent f1a8268 commit 91bf7f7

File tree

1 file changed

+20
-1
lines changed
  • services/datalake/pod-datalake/src/datalake

1 file changed

+20
-1
lines changed

services/datalake/pod-datalake/src/datalake/db.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ export function escape (value: any): string {
560560
}
561561

562562
function getMigrations (): [string, string][] {
563-
return [migrationV1()]
563+
return [migrationV1(), migrationV2()]
564564
}
565565

566566
function migrationV1 (): [string, string] {
@@ -599,3 +599,22 @@ function migrationV1 (): [string, string] {
599599
`
600600
return ['init_tables_01', sql]
601601
}
602+
603+
function migrationV2 (): [string, string] {
604+
const sql = `
605+
ALTER TABLE blob.meta DROP CONSTRAINT IF EXISTS fk_blob;
606+
607+
UPDATE blob.blob
608+
SET workspace = w.uuid
609+
FROM global_account.workspace w
610+
WHERE workspace = w.data_id;
611+
612+
UPDATE blob.meta
613+
SET workspace = w.uuid
614+
FROM global_account.workspace w
615+
WHERE workspace = w.data_id;
616+
617+
ALTER TABLE blob.meta ADD CONSTRAINT fk_blob FOREIGN KEY (workspace, name) REFERENCES blob.blob (workspace, name);
618+
`
619+
return ['migrate_workspaces_02', sql]
620+
}

0 commit comments

Comments
 (0)