Skip to content
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

Remove project id from db #231

Merged
merged 8 commits into from
Jan 27, 2025
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 collections_uniq_title_idx;

DROP INDEX collections_project_id_idx;
ALTER TABLE collections DROP COLUMN project_id;

CREATE UNIQUE INDEX collections_uniq_title_idx
ON collections (
COALESCE(parent_id::text, tenant_id),
title_lower
)
WHERE deleted_at IS NULL;
`);
}

export async function down(knex: Knex): Promise<void> {
return knex.raw(`
DROP INDEX collections_uniq_title_idx;

ALTER TABLE collections ADD COLUMN project_id TEXT DEFAULT NULL;
CREATE INDEX collections_project_id_idx ON collections USING BTREE (project_id);

CREATE UNIQUE INDEX collections_uniq_title_idx
ON collections (
COALESCE(parent_id::text, project_id, tenant_id),
title_lower
)
WHERE deleted_at IS NULL;
`);
}
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 DEFAULT NULL;
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;
`);
}
Loading