diff --git a/apps/server/src/database/migrations/1696635925309-page_children.ts b/apps/server/src/database/migrations/1696635925309-page_children.ts deleted file mode 100644 index ac841324..00000000 --- a/apps/server/src/database/migrations/1696635925309-page_children.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class PageChildren1696635925309 implements MigrationInterface { - name = 'PageChildren1696635925309' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" ADD "children" uuid array NOT NULL DEFAULT '{}'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "children"`); - } - -} diff --git a/apps/server/src/database/migrations/1696699967408-add-page-order-to-workspace.ts b/apps/server/src/database/migrations/1696699967408-add-page-order-to-workspace.ts deleted file mode 100644 index 35695b93..00000000 --- a/apps/server/src/database/migrations/1696699967408-add-page-order-to-workspace.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddPageOrderToWorkspace1696699967408 implements MigrationInterface { - name = 'AddPageOrderToWorkspace1696699967408' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" ADD "pageOrder" uuid array NOT NULL DEFAULT '{}'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" DROP COLUMN "pageOrder"`); - } - -} diff --git a/apps/server/src/database/migrations/1697150118968-PageOrdering.ts b/apps/server/src/database/migrations/1697150118968-PageOrdering.ts index 36555353..a0608df2 100644 --- a/apps/server/src/database/migrations/1697150118968-PageOrdering.ts +++ b/apps/server/src/database/migrations/1697150118968-PageOrdering.ts @@ -4,7 +4,7 @@ export class PageOrdering1697150118968 implements MigrationInterface { name = 'PageOrdering1697150118968' public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "page_ordering" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "entityId" uuid NOT NULL, "entityType" character varying(50) NOT NULL, "pageIds" uuid array, "workspaceId" uuid NOT NULL, CONSTRAINT "UQ_e6cab6ffd743697e73340ab10d5" UNIQUE ("entityId", "entityType"), CONSTRAINT "PK_9e76aa1ebbdb85f27813865a058" PRIMARY KEY ("id"))`); + await queryRunner.query(`CREATE TABLE "page_ordering" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "entityId" uuid NOT NULL, "entityType" character varying(50) NOT NULL, "childrenIds" uuid array NOT NULL DEFAULT '{}', "workspaceId" uuid NOT NULL, "deletedAt" TIMESTAMP, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_e6cab6ffd743697e73340ab10d5" UNIQUE ("entityId", "entityType"), CONSTRAINT "PK_9e76aa1ebbdb85f27813865a058" PRIMARY KEY ("id"))`); await queryRunner.query(`ALTER TABLE "page_ordering" ADD CONSTRAINT "FK_d08d863564fa1d5ed7a45d0e4ff" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); } diff --git a/apps/server/src/database/migrations/1697314563977-AddDefaultToChildrenIds.ts b/apps/server/src/database/migrations/1697314563977-AddDefaultToChildrenIds.ts deleted file mode 100644 index c8f369f7..00000000 --- a/apps/server/src/database/migrations/1697314563977-AddDefaultToChildrenIds.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddDefaultToChildrenIds1697314563977 implements MigrationInterface { - name = 'AddDefaultToChildrenIds1697314563977' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "page_ordering" ADD "deletedAt" TIMESTAMP`); - await queryRunner.query(`ALTER TABLE "page_ordering" ADD "createdAt" TIMESTAMP NOT NULL DEFAULT now()`); - await queryRunner.query(`ALTER TABLE "page_ordering" ADD "updatedAt" TIMESTAMP NOT NULL DEFAULT now()`); - await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" SET DEFAULT ARRAY[]::uuid[]`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" DROP DEFAULT`); - await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "page_ordering" DROP COLUMN "updatedAt"`); - await queryRunner.query(`ALTER TABLE "page_ordering" DROP COLUMN "createdAt"`); - await queryRunner.query(`ALTER TABLE "page_ordering" DROP COLUMN "deletedAt"`); - } - -} diff --git a/apps/server/src/database/migrations/1697314976326-FixPageOrdering.ts b/apps/server/src/database/migrations/1697314976326-FixPageOrdering.ts deleted file mode 100644 index ecaf6ee8..00000000 --- a/apps/server/src/database/migrations/1697314976326-FixPageOrdering.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class FixPageOrdering1697314976326 implements MigrationInterface { - name = 'FixPageOrdering1697314976326' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" SET DEFAULT ARRAY[]::uuid[]`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" SET DEFAULT ARRAY[]::uuid[]`); - } - -} diff --git a/apps/server/src/database/migrations/1697316172733-FixPageOrderingNext.ts b/apps/server/src/database/migrations/1697316172733-FixPageOrderingNext.ts deleted file mode 100644 index 14d456e6..00000000 --- a/apps/server/src/database/migrations/1697316172733-FixPageOrderingNext.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class FixPageOrderingNext1697316172733 implements MigrationInterface { - name = 'FixPageOrderingNext1697316172733' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "children"`); - await queryRunner.query(`ALTER TABLE "workspaces" DROP COLUMN "pageOrder"`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" ADD "pageOrder" uuid array NOT NULL DEFAULT '{}'`); - await queryRunner.query(`ALTER TABLE "pages" ADD "children" uuid array NOT NULL DEFAULT '{}'`); - } - -} diff --git a/apps/server/src/database/migrations/1698947225315-Comments.ts b/apps/server/src/database/migrations/1698947225315-Comments.ts index 6cb8efc8..09ced29d 100644 --- a/apps/server/src/database/migrations/1698947225315-Comments.ts +++ b/apps/server/src/database/migrations/1698947225315-Comments.ts @@ -5,7 +5,6 @@ export class Comments1698947225315 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TABLE "comments" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "content" text NOT NULL, "selection" character varying(255), "type" character varying(55), "creatorId" uuid NOT NULL, "pageId" uuid NOT NULL, "parentCommentId" uuid, "resolvedById" uuid, "resolvedAt" TIMESTAMP, "workspaceId" uuid NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "editedAt" TIMESTAMP, "deletedAt" TIMESTAMP, CONSTRAINT "PK_8bf68bc960f2b69e818bdb90dcb" PRIMARY KEY ("id"))`); - await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" SET DEFAULT ARRAY[]::uuid[]`); await queryRunner.query(`ALTER TABLE "comments" ADD CONSTRAINT "FK_0b42c764851bcb3ffae634792bc" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE "comments" ADD CONSTRAINT "FK_824db5aaea3cd415ff5c4074f03" FOREIGN KEY ("pageId") REFERENCES "pages"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE "comments" ADD CONSTRAINT "FK_4875672591221a61ace66f2d4f9" FOREIGN KEY ("parentCommentId") REFERENCES "comments"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); @@ -19,7 +18,6 @@ export class Comments1698947225315 implements MigrationInterface { await queryRunner.query(`ALTER TABLE "comments" DROP CONSTRAINT "FK_4875672591221a61ace66f2d4f9"`); await queryRunner.query(`ALTER TABLE "comments" DROP CONSTRAINT "FK_824db5aaea3cd415ff5c4074f03"`); await queryRunner.query(`ALTER TABLE "comments" DROP CONSTRAINT "FK_0b42c764851bcb3ffae634792bc"`); - await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" SET DEFAULT ARRAY[]::uuid[]`); await queryRunner.query(`DROP TABLE "comments"`); } diff --git a/apps/server/src/database/migrations/1699136384454-change-comments-content-type.ts b/apps/server/src/database/migrations/1699136384454-change-comments-content-type.ts index 7bcb7603..98619dd1 100644 --- a/apps/server/src/database/migrations/1699136384454-change-comments-content-type.ts +++ b/apps/server/src/database/migrations/1699136384454-change-comments-content-type.ts @@ -12,5 +12,4 @@ export class ChangeCommentsContentType1699136384454 implements MigrationInterfac await queryRunner.query(`ALTER TABLE "comments" DROP COLUMN "content"`); await queryRunner.query(`ALTER TABLE "comments" ADD "content" text NOT NULL`); } - } diff --git a/apps/server/src/database/migrations/1699745066813-add_lastUpdatedById-to-page.ts b/apps/server/src/database/migrations/1699745066813-add_lastUpdatedById-to-page.ts index 4ceda80a..4a2f8b24 100644 --- a/apps/server/src/database/migrations/1699745066813-add_lastUpdatedById-to-page.ts +++ b/apps/server/src/database/migrations/1699745066813-add_lastUpdatedById-to-page.ts @@ -5,13 +5,11 @@ export class AddLastUpdatedByIdToPage1699745066813 implements MigrationInterface public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "pages" ADD "lastUpdatedById" uuid`); - await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" DROP DEFAULT`); await queryRunner.query(`ALTER TABLE "pages" ADD CONSTRAINT "FK_084265d943e0013761a6d6478e0" FOREIGN KEY ("lastUpdatedById") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "pages" DROP CONSTRAINT "FK_084265d943e0013761a6d6478e0"`); - await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" SET DEFAULT ARRAY[]`); await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "lastUpdatedById"`); } diff --git a/apps/server/src/database/migrations/1706450034470-AddTsvectorColumn.ts b/apps/server/src/database/migrations/1706450034470-AddTsvectorColumn.ts deleted file mode 100644 index 43732b7b..00000000 --- a/apps/server/src/database/migrations/1706450034470-AddTsvectorColumn.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTsvectorColumn1706450034470 implements MigrationInterface { - name = 'AddTsvectorColumn1706450034470' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" ADD "tsv" tsvector GENERATED ALWAYS AS (setweight(to_tsvector('english', coalesce(pages.title, '')), 'A') || setweight(to_tsvector('english', coalesce(pages."textContent", '')), 'B')) STORED`); - await queryRunner.query(`INSERT INTO "typeorm_metadata"("database", "schema", "table", "type", "name", "value") VALUES ($1, $2, $3, $4, $5, $6)`, ["","public","pages","GENERATED_COLUMN","tsv","setweight(to_tsvector('english', coalesce(pages.title, '')), 'A') || setweight(to_tsvector('english', coalesce(pages.\"textContent\", '')), 'B')"]); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DELETE FROM "typeorm_metadata" WHERE "type" = $1 AND "name" = $2 AND "database" = $3 AND "schema" = $4 AND "table" = $5`, ["GENERATED_COLUMN","tsv","","public","pages"]); - await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "tsv"`); - } - -}