-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove project_id from collections and workbooks tables
- Loading branch information
1 parent
7071dd4
commit 112376b
Showing
2 changed files
with
33 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/db/migrations/20250110092032_cleanup_project_id_from_workbooks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type {Knex} from 'knex'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
return knex.raw(` | ||
DROP INDEX workbooks_uniq_title_idx; | ||
DROP INDEX workbooks_project_id_idx; | ||
ALTER TABLE workbooks DROP COLUMN project_id; | ||
CREATE UNIQUE INDEX workbooks_uniq_title_idx | ||
ON workbooks ( | ||
COALESCE(collection_id::text, tenant_id), | ||
title_lower | ||
) | ||
WHERE deleted_at IS NULL; | ||
`); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
return knex.raw(` | ||
DROP INDEX workbooks_uniq_title_idx; | ||
ALTER TABLE workbooks ADD COLUMN project_id TEXT; | ||
CREATE INDEX workbooks_project_id_idx ON workbooks USING BTREE (project_id); | ||
CREATE UNIQUE INDEX workbooks_uniq_title_idx | ||
ON workbooks ( | ||
COALESCE(collection_id::text, project_id, tenant_id), | ||
title_lower | ||
) | ||
WHERE deleted_at IS NULL; | ||
`); | ||
} |