Skip to content

UBERF-11178 Migrate datalake workspace id #9092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion services/datalake/pod-datalake/src/datalake/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ export function escape (value: any): string {
}

function getMigrations (): [string, string][] {
return [migrationV1()]
return [migrationV1(), migrationV2()]
}

function migrationV1 (): [string, string] {
Expand Down Expand Up @@ -599,3 +599,22 @@ function migrationV1 (): [string, string] {
`
return ['init_tables_01', sql]
}

function migrationV2 (): [string, string] {
const sql = `
ALTER TABLE blob.meta DROP CONSTRAINT IF EXISTS fk_blob;

UPDATE blob.blob
SET workspace = w.uuid
FROM global_account.workspace w
WHERE workspace = w.data_id;

UPDATE blob.meta
SET workspace = w.uuid
FROM global_account.workspace w
WHERE workspace = w.data_id;

ALTER TABLE blob.meta ADD CONSTRAINT fk_blob FOREIGN KEY (workspace, name) REFERENCES blob.blob (workspace, name);
`
return ['migrate_workspaces_02', sql]
}
Loading