diff --git a/apps/server/src/database/migrations/1693002768219-init.ts b/apps/server/src/database/migrations/1693002768219-init.ts deleted file mode 100644 index 6d8966c4..00000000 --- a/apps/server/src/database/migrations/1693002768219-init.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Init1693002768219 implements MigrationInterface { - name = 'Init1693002768219' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "workspace_users" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "userId" uuid NOT NULL, "workspaceId" uuid NOT NULL, "role" character varying(100), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_fe4f6e13489c4ad1a946910f529" UNIQUE ("workspaceId", "userId"), CONSTRAINT "PK_6d52a8e2739982d783279cffe84" PRIMARY KEY ("id"))`); - await queryRunner.query(`CREATE TABLE "pages" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "title" character varying(500), "content" text, "html" text, "json" jsonb, "slug" character varying, "icon" character varying, "coverPhoto" character varying, "editor" character varying(255), "shareId" character varying(255), "parentPageId" uuid, "creatorId" uuid NOT NULL, "workspaceId" uuid NOT NULL, "isLocked" boolean NOT NULL DEFAULT false, "status" character varying(255), "publishedAt" date, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP, CONSTRAINT "PK_8f21ed625aa34c8391d636b7d3b" PRIMARY KEY ("id"))`); - await queryRunner.query(`CREATE TABLE "workspace_invitations" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "workspaceId" uuid NOT NULL, "invitedById" uuid NOT NULL, "email" character varying(255) NOT NULL, "role" character varying(100), "status" character varying(100), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_525b9069dc828a8ee8fdc62c32c" PRIMARY KEY ("id"))`); - await queryRunner.query(`CREATE TABLE "workspaces" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying(255), "description" text, "logo" character varying(255), "hostname" character varying(255), "customDomain" character varying(255), "enableInvite" boolean NOT NULL DEFAULT true, "inviteCode" character varying(255), "settings" jsonb, "creatorId" uuid NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_3e610433bc1050e8b95ba5f40b3" UNIQUE ("hostname"), CONSTRAINT "UQ_a2c9d7a0bc273471872ecdbcfd9" UNIQUE ("inviteCode"), CONSTRAINT "PK_098656ae401f3e1a4586f47fd8e" PRIMARY KEY ("id"))`); - await queryRunner.query(`CREATE TABLE "users" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying(255), "email" character varying(255) NOT NULL, "emailVerifiedAt" TIMESTAMP, "password" character varying NOT NULL, "avatarUrl" character varying, "locale" character varying(100), "timezone" character varying(300), "settings" jsonb, "lastLoginAt" TIMESTAMP, "lastLoginIp" character varying(100), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_97672ac88f789774dd47f7c8be3" UNIQUE ("email"), CONSTRAINT "PK_a3ffb1c0c8416b9fc6f907b7433" PRIMARY KEY ("id"))`); - await queryRunner.query(`ALTER TABLE "workspace_users" ADD CONSTRAINT "FK_70db33ab07e28bfa1fc6011d4ee" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "workspace_users" ADD CONSTRAINT "FK_9b226f3cec0ffab646d5607a0c5" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "pages" ADD CONSTRAINT "FK_a8c1826f1ff30a4a6afd3344ad5" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "pages" ADD CONSTRAINT "FK_2043118dc32860c1a4f02c94dcf" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "pages" ADD CONSTRAINT "FK_824728b97cb88f81f00dd333da1" FOREIGN KEY ("parentPageId") REFERENCES "pages"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "workspace_invitations" ADD CONSTRAINT "FK_65515eaafd8282c3848bddbb008" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "workspace_invitations" ADD CONSTRAINT "FK_5d5dd20ac2ce5f9b80d47ea4f09" FOREIGN KEY ("invitedById") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "workspaces" ADD CONSTRAINT "FK_2aab2dd12dc65eb183d99b953e0" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" DROP CONSTRAINT "FK_2aab2dd12dc65eb183d99b953e0"`); - await queryRunner.query(`ALTER TABLE "workspace_invitations" DROP CONSTRAINT "FK_5d5dd20ac2ce5f9b80d47ea4f09"`); - await queryRunner.query(`ALTER TABLE "workspace_invitations" DROP CONSTRAINT "FK_65515eaafd8282c3848bddbb008"`); - await queryRunner.query(`ALTER TABLE "pages" DROP CONSTRAINT "FK_824728b97cb88f81f00dd333da1"`); - await queryRunner.query(`ALTER TABLE "pages" DROP CONSTRAINT "FK_2043118dc32860c1a4f02c94dcf"`); - await queryRunner.query(`ALTER TABLE "pages" DROP CONSTRAINT "FK_a8c1826f1ff30a4a6afd3344ad5"`); - await queryRunner.query(`ALTER TABLE "workspace_users" DROP CONSTRAINT "FK_9b226f3cec0ffab646d5607a0c5"`); - await queryRunner.query(`ALTER TABLE "workspace_users" DROP CONSTRAINT "FK_70db33ab07e28bfa1fc6011d4ee"`); - await queryRunner.query(`DROP TABLE "users"`); - await queryRunner.query(`DROP TABLE "workspaces"`); - await queryRunner.query(`DROP TABLE "workspace_invitations"`); - await queryRunner.query(`DROP TABLE "pages"`); - await queryRunner.query(`DROP TABLE "workspace_users"`); - } - -} diff --git a/apps/server/src/database/migrations/1694305155156-add_ydoc.ts b/apps/server/src/database/migrations/1694305155156-add_ydoc.ts deleted file mode 100644 index 72f12736..00000000 --- a/apps/server/src/database/migrations/1694305155156-add_ydoc.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddYdoc1694305155156 implements MigrationInterface { - name = 'AddYdoc1694305155156' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" RENAME COLUMN "json" TO "ydoc"`); - await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "ydoc"`); - await queryRunner.query(`ALTER TABLE "pages" ADD "ydoc" bytea`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "ydoc"`); - await queryRunner.query(`ALTER TABLE "pages" ADD "ydoc" jsonb`); - await queryRunner.query(`ALTER TABLE "pages" RENAME COLUMN "ydoc" TO "json"`); - } - -} diff --git a/apps/server/src/database/migrations/1694385231850-change-content-type-to-json.ts b/apps/server/src/database/migrations/1694385231850-change-content-type-to-json.ts deleted file mode 100644 index e04faac4..00000000 --- a/apps/server/src/database/migrations/1694385231850-change-content-type-to-json.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class ChangeContentTypeToJson1694385231850 implements MigrationInterface { - name = 'ChangeContentTypeToJson1694385231850' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "content"`); - await queryRunner.query(`ALTER TABLE "pages" ADD "content" jsonb`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "content"`); - await queryRunner.query(`ALTER TABLE "pages" ADD "content" text`); - } - -} diff --git a/apps/server/src/database/migrations/1697150118968-PageOrdering.ts b/apps/server/src/database/migrations/1697150118968-PageOrdering.ts deleted file mode 100644 index a0608df2..00000000 --- a/apps/server/src/database/migrations/1697150118968-PageOrdering.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -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, "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`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "page_ordering" DROP CONSTRAINT "FK_d08d863564fa1d5ed7a45d0e4ff"`); - await queryRunner.query(`DROP TABLE "page_ordering"`); - } - -} diff --git a/apps/server/src/database/migrations/1698947225315-Comments.ts b/apps/server/src/database/migrations/1698947225315-Comments.ts deleted file mode 100644 index 09ced29d..00000000 --- a/apps/server/src/database/migrations/1698947225315-Comments.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Comments1698947225315 implements MigrationInterface { - name = 'Comments1698947225315' - - 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 "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`); - await queryRunner.query(`ALTER TABLE "comments" ADD CONSTRAINT "FK_79d04b0fd3e4be189fd14d5ff87" FOREIGN KEY ("resolvedById") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "comments" ADD CONSTRAINT "FK_9e54f4464009dbc27921fd5f166" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "comments" DROP CONSTRAINT "FK_9e54f4464009dbc27921fd5f166"`); - await queryRunner.query(`ALTER TABLE "comments" DROP CONSTRAINT "FK_79d04b0fd3e4be189fd14d5ff87"`); - 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(`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 deleted file mode 100644 index 98619dd1..00000000 --- a/apps/server/src/database/migrations/1699136384454-change-comments-content-type.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class ChangeCommentsContentType1699136384454 implements MigrationInterface { - name = 'ChangeCommentsContentType1699136384454' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "comments" DROP COLUMN "content"`); - await queryRunner.query(`ALTER TABLE "comments" ADD "content" jsonb`); - } - - public async down(queryRunner: QueryRunner): Promise { - 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/1699459398217-cascade-children-comments.ts b/apps/server/src/database/migrations/1699459398217-cascade-children-comments.ts deleted file mode 100644 index 69716377..00000000 --- a/apps/server/src/database/migrations/1699459398217-cascade-children-comments.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class CascadeChildrenComments1699459398217 implements MigrationInterface { - name = 'CascadeChildrenComments1699459398217' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "comments" DROP CONSTRAINT "FK_4875672591221a61ace66f2d4f9"`); - await queryRunner.query(`ALTER TABLE "comments" ADD CONSTRAINT "FK_4875672591221a61ace66f2d4f9" FOREIGN KEY ("parentCommentId") REFERENCES "comments"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "comments" DROP CONSTRAINT "FK_4875672591221a61ace66f2d4f9"`); - await queryRunner.query(`ALTER TABLE "comments" ADD CONSTRAINT "FK_4875672591221a61ace66f2d4f9" FOREIGN KEY ("parentCommentId") REFERENCES "comments"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - -} 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 deleted file mode 100644 index 4a2f8b24..00000000 --- a/apps/server/src/database/migrations/1699745066813-add_lastUpdatedById-to-page.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddLastUpdatedByIdToPage1699745066813 implements MigrationInterface { - name = 'AddLastUpdatedByIdToPage1699745066813' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" ADD "lastUpdatedById" uuid`); - 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 "pages" DROP COLUMN "lastUpdatedById"`); - } - -} diff --git a/apps/server/src/database/migrations/1699746184234-add_deletedById-to-page.ts b/apps/server/src/database/migrations/1699746184234-add_deletedById-to-page.ts deleted file mode 100644 index 9fcbb085..00000000 --- a/apps/server/src/database/migrations/1699746184234-add_deletedById-to-page.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddDeletedByIdToPage1699746184234 implements MigrationInterface { - name = 'AddDeletedByIdToPage1699746184234' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" ADD "deletedById" uuid`); - await queryRunner.query(`ALTER TABLE "pages" ADD CONSTRAINT "FK_189f605351a31458e0e30c8a9cb" FOREIGN KEY ("deletedById") 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_189f605351a31458e0e30c8a9cb"`); - await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "deletedById"`); - } - -} diff --git a/apps/server/src/database/migrations/1699994428641-pageHistory.ts b/apps/server/src/database/migrations/1699994428641-pageHistory.ts deleted file mode 100644 index c8ad71d2..00000000 --- a/apps/server/src/database/migrations/1699994428641-pageHistory.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class PageHistory1699994428641 implements MigrationInterface { - name = 'PageHistory1699994428641' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "page_history" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "pageId" uuid NOT NULL, "title" character varying(500), "content" jsonb, "slug" character varying, "icon" character varying, "coverPhoto" character varying, "version" integer NOT NULL, "lastUpdatedById" uuid NOT NULL, "workspaceId" uuid NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_691fc6c1929979d997d632fce15" PRIMARY KEY ("id"))`); - await queryRunner.query(`ALTER TABLE "page_history" ADD CONSTRAINT "FK_aa0d880237a50235094b861fa10" FOREIGN KEY ("pageId") REFERENCES "pages"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "page_history" ADD CONSTRAINT "FK_7be5dfbbbb81607688a5032516d" FOREIGN KEY ("lastUpdatedById") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "page_history" ADD CONSTRAINT "FK_9cc322c0c40d5d3356911e24ce0" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "page_history" DROP CONSTRAINT "FK_9cc322c0c40d5d3356911e24ce0"`); - await queryRunner.query(`ALTER TABLE "page_history" DROP CONSTRAINT "FK_7be5dfbbbb81607688a5032516d"`); - await queryRunner.query(`ALTER TABLE "page_history" DROP CONSTRAINT "FK_aa0d880237a50235094b861fa10"`); - await queryRunner.query(`DROP TABLE "page_history"`); - } - -} diff --git a/apps/server/src/database/migrations/1700915691852-attachments.ts b/apps/server/src/database/migrations/1700915691852-attachments.ts deleted file mode 100644 index 7af53c33..00000000 --- a/apps/server/src/database/migrations/1700915691852-attachments.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Attachments1700915691852 implements MigrationInterface { - name = 'Attachments1700915691852' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "attachments" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "fileName" character varying(255) NOT NULL, "filePath" character varying NOT NULL, "fileSize" bigint NOT NULL, "fileExt" character varying(55) NOT NULL, "mimeType" character varying(255) NOT NULL, "type" character varying(55) NOT NULL, "creatorId" uuid NOT NULL, "pageId" uuid, "workspaceId" uuid NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP, CONSTRAINT "PK_5e1f050bcff31e3084a1d662412" PRIMARY KEY ("id"))`); - await queryRunner.query(`ALTER TABLE "attachments" ADD CONSTRAINT "FK_daa9e88b284de90deec949dd18a" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "attachments" ADD CONSTRAINT "FK_60c2231004f3ca0e1808960eaf4" FOREIGN KEY ("pageId") REFERENCES "pages"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "attachments" ADD CONSTRAINT "FK_324ff4215dd2fdad52a8d5e2dfd" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "attachments" DROP CONSTRAINT "FK_324ff4215dd2fdad52a8d5e2dfd"`); - await queryRunner.query(`ALTER TABLE "attachments" DROP CONSTRAINT "FK_60c2231004f3ca0e1808960eaf4"`); - await queryRunner.query(`ALTER TABLE "attachments" DROP CONSTRAINT "FK_daa9e88b284de90deec949dd18a"`); - await queryRunner.query(`DROP TABLE "attachments"`); - } - -} diff --git a/apps/server/src/database/migrations/1701130054626-allowNullableWorkspaceIdInAttachment.ts b/apps/server/src/database/migrations/1701130054626-allowNullableWorkspaceIdInAttachment.ts deleted file mode 100644 index 8a1ed901..00000000 --- a/apps/server/src/database/migrations/1701130054626-allowNullableWorkspaceIdInAttachment.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AllowNullableWorkspaceIdInAttachment1701130054626 implements MigrationInterface { - name = 'AllowNullableWorkspaceIdInAttachment1701130054626' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "attachments" DROP CONSTRAINT "FK_324ff4215dd2fdad52a8d5e2dfd"`); - await queryRunner.query(`ALTER TABLE "attachments" ALTER COLUMN "workspaceId" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "attachments" ADD CONSTRAINT "FK_324ff4215dd2fdad52a8d5e2dfd" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "attachments" DROP CONSTRAINT "FK_324ff4215dd2fdad52a8d5e2dfd"`); - await queryRunner.query(`ALTER TABLE "attachments" ALTER COLUMN "workspaceId" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "attachments" ADD CONSTRAINT "FK_324ff4215dd2fdad52a8d5e2dfd" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } - -} diff --git a/apps/server/src/database/migrations/1706304317371-AddTextContentColumn.ts b/apps/server/src/database/migrations/1706304317371-AddTextContentColumn.ts deleted file mode 100644 index ac2b1161..00000000 --- a/apps/server/src/database/migrations/1706304317371-AddTextContentColumn.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddTextContentColumn1706304317371 implements MigrationInterface { - name = 'AddTextContentColumn1706304317371' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" ADD "textContent" text`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "textContent"`); - } - -} 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 d335dba6..00000000 --- a/apps/server/src/database/migrations/1706450034470-AddTsvectorColumn.ts +++ /dev/null @@ -1,13 +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`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "tsv"`); - } -} diff --git a/apps/server/src/database/migrations/1706450034471-AddTsvectorTrigger.ts b/apps/server/src/database/migrations/1706450034471-AddTsvectorTrigger.ts deleted file mode 100644 index f0b2c744..00000000 --- a/apps/server/src/database/migrations/1706450034471-AddTsvectorTrigger.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddTsvectorTrigger1706450034471 implements MigrationInterface { - name = 'AddTsvectorTrigger1706450034471'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - CREATE FUNCTION pages_tsvector_trigger() RETURNS trigger AS $$ - begin - new.tsv := - setweight(to_tsvector('english', coalesce(new.title, '')), 'A') || - setweight(to_tsvector('english', coalesce(new.\"textContent\", '')), 'B'); - return new; - end; - $$ LANGUAGE plpgsql; - `); - - await queryRunner.query(` - CREATE TRIGGER pages_tsvector_update BEFORE INSERT OR UPDATE - ON pages FOR EACH ROW EXECUTE FUNCTION pages_tsvector_trigger(); - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DROP TRIGGER pages_tsvector_update ON Pages`); - await queryRunner.query(`DROP FUNCTION pages_tsvector_trigger`); - } -} diff --git a/apps/server/src/database/migrations/1706453158729-AddIndexTSVColumn.ts b/apps/server/src/database/migrations/1706453158729-AddIndexTSVColumn.ts deleted file mode 100644 index 22dfd584..00000000 --- a/apps/server/src/database/migrations/1706453158729-AddIndexTSVColumn.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddIndexTSVColumn1706453158729 implements MigrationInterface { - name = 'AddIndexTSVColumn1706453158729' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DROP INDEX IF EXISTS pages_tsv_idx;`); - await queryRunner.query(`CREATE INDEX pages_tsv_idx ON pages USING GIN ("tsv");`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DROP INDEX IF EXISTS pages_tsv_idx;`); - } -} diff --git a/apps/server/src/database/migrations/1706807570313-Spaces.ts b/apps/server/src/database/migrations/1706807570313-Spaces.ts deleted file mode 100644 index 6119e749..00000000 --- a/apps/server/src/database/migrations/1706807570313-Spaces.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Spaces1706807570313 implements MigrationInterface { - name = 'Spaces1706807570313' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "spaces" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying(255), "description" text, "icon" character varying(255), "hostname" character varying(255), "creatorId" uuid NOT NULL, "workspaceId" uuid NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_4f0a029f6eefd773fde2143b261" UNIQUE ("hostname"), CONSTRAINT "PK_dbe542974aca57afcb60709d4c8" PRIMARY KEY ("id"))`); - await queryRunner.query(`ALTER TABLE "page_history" ADD "spaceId" uuid NOT NULL`); - await queryRunner.query(`ALTER TABLE "pages" ADD "spaceId" uuid NOT NULL`); - await queryRunner.query(`ALTER TABLE "page_ordering" ADD "spaceId" uuid NOT NULL`); - await queryRunner.query(`ALTER TABLE "spaces" ADD CONSTRAINT "FK_8469f60fb94d43a0280a83d0b35" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "spaces" ADD CONSTRAINT "FK_f8c6dec54d8a2fdd26ea036fc8d" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "page_history" ADD CONSTRAINT "FK_8caa9d435480f4390b9885c4bd0" FOREIGN KEY ("spaceId") REFERENCES "spaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "pages" ADD CONSTRAINT "FK_c4aef9b23f1222bebc5897de72d" FOREIGN KEY ("spaceId") REFERENCES "spaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "page_ordering" ADD CONSTRAINT "FK_17f9d5fd14d32a81d58ad747359" FOREIGN KEY ("spaceId") REFERENCES "spaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "page_ordering" DROP CONSTRAINT "FK_17f9d5fd14d32a81d58ad747359"`); - await queryRunner.query(`ALTER TABLE "pages" DROP CONSTRAINT "FK_c4aef9b23f1222bebc5897de72d"`); - await queryRunner.query(`ALTER TABLE "page_history" DROP CONSTRAINT "FK_8caa9d435480f4390b9885c4bd0"`); - await queryRunner.query(`ALTER TABLE "spaces" DROP CONSTRAINT "FK_f8c6dec54d8a2fdd26ea036fc8d"`); - await queryRunner.query(`ALTER TABLE "spaces" DROP CONSTRAINT "FK_8469f60fb94d43a0280a83d0b35"`); - await queryRunner.query(`ALTER TABLE "page_ordering" DROP COLUMN "spaceId"`); - await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "spaceId"`); - await queryRunner.query(`ALTER TABLE "page_history" DROP COLUMN "spaceId"`); - await queryRunner.query(`DROP TABLE "spaces"`); - } - -} diff --git a/apps/server/src/database/migrations/1709215284760-defaultSpace.ts b/apps/server/src/database/migrations/1709215284760-defaultSpace.ts deleted file mode 100644 index c2011238..00000000 --- a/apps/server/src/database/migrations/1709215284760-defaultSpace.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class DefaultSpace1709215284760 implements MigrationInterface { - name = 'DefaultSpace1709215284760' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" ADD "defaultSpaceId" uuid`); - await queryRunner.query(`ALTER TABLE "workspaces" ADD CONSTRAINT "UQ_e91d3ec686ece9654aa9f635981" UNIQUE ("defaultSpaceId")`); - await queryRunner.query(`ALTER TABLE "workspaces" ADD CONSTRAINT "FK_e91d3ec686ece9654aa9f635981" FOREIGN KEY ("defaultSpaceId") REFERENCES "spaces"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" DROP CONSTRAINT "FK_e91d3ec686ece9654aa9f635981"`); - await queryRunner.query(`ALTER TABLE "workspaces" DROP CONSTRAINT "UQ_e91d3ec686ece9654aa9f635981"`); - await queryRunner.query(`ALTER TABLE "workspaces" DROP COLUMN "defaultSpaceId"`); - } - -} diff --git a/apps/server/src/database/migrations/1709644512305-Groups.ts b/apps/server/src/database/migrations/1709644512305-Groups.ts deleted file mode 100644 index 8abec0fc..00000000 --- a/apps/server/src/database/migrations/1709644512305-Groups.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class Groups1709644512305 implements MigrationInterface { - name = 'Groups1709644512305' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "group_users" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "userId" uuid NOT NULL, "groupId" uuid NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_129c2cb846b1f4beedf4c6373b5" UNIQUE ("groupId", "userId"), CONSTRAINT "PK_5df8869cdeffc693bd083153bcf" PRIMARY KEY ("id"))`); - await queryRunner.query(`CREATE TABLE "groups" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying(255) NOT NULL, "description" text, "workspaceId" uuid NOT NULL, "creatorId" uuid NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_659d1483316afb28afd3a90646e" PRIMARY KEY ("id"))`); - await queryRunner.query(`ALTER TABLE "group_users" ADD CONSTRAINT "FK_ad937045ed48b757293b2011d36" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "group_users" ADD CONSTRAINT "FK_ba2d59b482905354e872896dba8" FOREIGN KEY ("groupId") REFERENCES "groups"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "groups" ADD CONSTRAINT "FK_cce5e5fec33dae0fcc991795b4a" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "groups" ADD CONSTRAINT "FK_accb24ba8f4f213f33d08e2a20f" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "groups" DROP CONSTRAINT "FK_accb24ba8f4f213f33d08e2a20f"`); - await queryRunner.query(`ALTER TABLE "groups" DROP CONSTRAINT "FK_cce5e5fec33dae0fcc991795b4a"`); - await queryRunner.query(`ALTER TABLE "group_users" DROP CONSTRAINT "FK_ba2d59b482905354e872896dba8"`); - await queryRunner.query(`ALTER TABLE "group_users" DROP CONSTRAINT "FK_ad937045ed48b757293b2011d36"`); - await queryRunner.query(`DROP TABLE "groups"`); - await queryRunner.query(`DROP TABLE "group_users"`); - } - -} diff --git a/apps/server/src/database/migrations/1710168946001-RefactorWorkspaceUser.ts b/apps/server/src/database/migrations/1710168946001-RefactorWorkspaceUser.ts deleted file mode 100644 index c543773e..00000000 --- a/apps/server/src/database/migrations/1710168946001-RefactorWorkspaceUser.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class RefactorWorkspaceUser1710168946001 implements MigrationInterface { - name = 'RefactorWorkspaceUser1710168946001' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" DROP CONSTRAINT "FK_2aab2dd12dc65eb183d99b953e0"`); - await queryRunner.query(`ALTER TABLE "users" ADD "role" character varying(100)`); - await queryRunner.query(`ALTER TABLE "users" ADD "workspaceId" uuid`); - await queryRunner.query(`ALTER TABLE "workspaces" ALTER COLUMN "creatorId" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ADD CONSTRAINT "FK_949fea12b7977a8b2f483bf802a" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "users" DROP CONSTRAINT "FK_949fea12b7977a8b2f483bf802a"`); - await queryRunner.query(`ALTER TABLE "workspaces" ALTER COLUMN "creatorId" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" DROP COLUMN "workspaceId"`); - await queryRunner.query(`ALTER TABLE "users" DROP COLUMN "role"`); - await queryRunner.query(`ALTER TABLE "workspaces" ADD CONSTRAINT "FK_2aab2dd12dc65eb183d99b953e0" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - -} diff --git a/apps/server/src/database/migrations/1710371336371-AddDeletedAtToWorkspace.ts b/apps/server/src/database/migrations/1710371336371-AddDeletedAtToWorkspace.ts deleted file mode 100644 index d555424c..00000000 --- a/apps/server/src/database/migrations/1710371336371-AddDeletedAtToWorkspace.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddDeletedAtToWorkspace1710371336371 implements MigrationInterface { - name = 'AddDeletedAtToWorkspace1710371336371' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" ADD "deletedAt" TIMESTAMP`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" DROP COLUMN "deletedAt"`); - } - -} diff --git a/apps/server/src/database/migrations/1710377632898-RemoveUniqueFromUserEmail.ts b/apps/server/src/database/migrations/1710377632898-RemoveUniqueFromUserEmail.ts deleted file mode 100644 index 1fd81807..00000000 --- a/apps/server/src/database/migrations/1710377632898-RemoveUniqueFromUserEmail.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class RemoveUniqueFromUserEmail1710377632898 implements MigrationInterface { - name = 'RemoveUniqueFromUserEmail1710377632898' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "users" DROP CONSTRAINT "UQ_97672ac88f789774dd47f7c8be3"`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "users" ADD CONSTRAINT "UQ_97672ac88f789774dd47f7c8be3" UNIQUE ("email")`); - } - -} diff --git a/apps/server/src/database/migrations/1710517114813-AddDefaultRoles.ts b/apps/server/src/database/migrations/1710517114813-AddDefaultRoles.ts deleted file mode 100644 index 827cc46d..00000000 --- a/apps/server/src/database/migrations/1710517114813-AddDefaultRoles.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddDefaultRoles1710517114813 implements MigrationInterface { - name = 'AddDefaultRoles1710517114813' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "spaces" DROP CONSTRAINT "UQ_4f0a029f6eefd773fde2143b261"`); - await queryRunner.query(`ALTER TABLE "spaces" DROP COLUMN "hostname"`); - await queryRunner.query(`ALTER TABLE "spaces" ADD "privacy" character varying(100) NOT NULL DEFAULT 'open'`); - await queryRunner.query(`ALTER TABLE "spaces" ADD "defaultRole" character varying(100) NOT NULL DEFAULT 'writer'`); - await queryRunner.query(`ALTER TABLE "workspaces" ADD "defaultRole" character varying NOT NULL DEFAULT 'member'`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" DROP COLUMN "defaultRole"`); - await queryRunner.query(`ALTER TABLE "spaces" DROP COLUMN "defaultRole"`); - await queryRunner.query(`ALTER TABLE "spaces" DROP COLUMN "privacy"`); - await queryRunner.query(`ALTER TABLE "spaces" ADD "hostname" character varying(255)`); - await queryRunner.query(`ALTER TABLE "spaces" ADD CONSTRAINT "UQ_4f0a029f6eefd773fde2143b261" UNIQUE ("hostname")`); - } - -} diff --git a/apps/server/src/database/migrations/1710530661379-UniqueUser.ts b/apps/server/src/database/migrations/1710530661379-UniqueUser.ts deleted file mode 100644 index 483e81be..00000000 --- a/apps/server/src/database/migrations/1710530661379-UniqueUser.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UniqueUser1710530661379 implements MigrationInterface { - name = 'UniqueUser1710530661379' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "users" ADD CONSTRAINT "UQ_b368db80982a952e3071e008a2c" UNIQUE ("email", "workspaceId")`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "users" DROP CONSTRAINT "UQ_b368db80982a952e3071e008a2c"`); - } - -} diff --git a/apps/server/src/database/migrations/1710615517137-SpaceSlug.ts b/apps/server/src/database/migrations/1710615517137-SpaceSlug.ts deleted file mode 100644 index 6a556d87..00000000 --- a/apps/server/src/database/migrations/1710615517137-SpaceSlug.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class SpaceSlug1710615517137 implements MigrationInterface { - name = 'SpaceSlug1710615517137' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "spaces" ADD "slug" character varying`); - await queryRunner.query(`ALTER TABLE "spaces" ADD CONSTRAINT "UQ_c58549749e7a141746940d01f39" UNIQUE ("slug", "workspaceId")`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "spaces" DROP CONSTRAINT "UQ_c58549749e7a141746940d01f39"`); - await queryRunner.query(`ALTER TABLE "spaces" DROP COLUMN "slug"`); - } - -} diff --git a/apps/server/src/database/migrations/1710886360227-AddDefaultGroup.ts b/apps/server/src/database/migrations/1710886360227-AddDefaultGroup.ts deleted file mode 100644 index 4ac3ab00..00000000 --- a/apps/server/src/database/migrations/1710886360227-AddDefaultGroup.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddDefaultGroup1710886360227 implements MigrationInterface { - name = 'AddDefaultGroup1710886360227' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "groups" ADD "isDefault" boolean NOT NULL DEFAULT false`); - await queryRunner.query(`ALTER TABLE "groups" DROP CONSTRAINT "FK_accb24ba8f4f213f33d08e2a20f"`); - await queryRunner.query(`ALTER TABLE "groups" ALTER COLUMN "creatorId" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "groups" ADD CONSTRAINT "UQ_c092c7c01795e6ad7af46bf2d24" UNIQUE ("name", "workspaceId")`); - await queryRunner.query(`ALTER TABLE "groups" ADD CONSTRAINT "FK_accb24ba8f4f213f33d08e2a20f" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "groups" DROP CONSTRAINT "FK_accb24ba8f4f213f33d08e2a20f"`); - await queryRunner.query(`ALTER TABLE "groups" DROP CONSTRAINT "UQ_c092c7c01795e6ad7af46bf2d24"`); - await queryRunner.query(`ALTER TABLE "groups" ALTER COLUMN "creatorId" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "groups" ADD CONSTRAINT "FK_accb24ba8f4f213f33d08e2a20f" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "groups" DROP COLUMN "isDefault"`); - } - -} diff --git a/apps/server/src/database/migrations/1710894465616-AddWorkspaceCascadeToUser.ts b/apps/server/src/database/migrations/1710894465616-AddWorkspaceCascadeToUser.ts deleted file mode 100644 index 17c0380f..00000000 --- a/apps/server/src/database/migrations/1710894465616-AddWorkspaceCascadeToUser.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddWorkspaceCascadeToUser1710894465616 implements MigrationInterface { - name = 'AddWorkspaceCascadeToUser1710894465616' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "users" DROP CONSTRAINT "FK_949fea12b7977a8b2f483bf802a"`); - await queryRunner.query(`ALTER TABLE "users" ADD CONSTRAINT "FK_949fea12b7977a8b2f483bf802a" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "users" DROP CONSTRAINT "FK_949fea12b7977a8b2f483bf802a"`); - await queryRunner.query(`ALTER TABLE "users" ADD CONSTRAINT "FK_949fea12b7977a8b2f483bf802a" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - -} diff --git a/apps/server/src/database/migrations/1711051968957-RenameSpacePrivacyColumn.ts b/apps/server/src/database/migrations/1711051968957-RenameSpacePrivacyColumn.ts deleted file mode 100644 index 4cfef259..00000000 --- a/apps/server/src/database/migrations/1711051968957-RenameSpacePrivacyColumn.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class RenameSpacePrivacyColumn1711051968957 implements MigrationInterface { - name = 'RenameSpacePrivacyColumn1711051968957' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "spaces" RENAME COLUMN "privacy" TO "visibility"`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "spaces" RENAME COLUMN "visibility" TO "privacy"`); - } - -} diff --git a/apps/server/src/database/migrations/1711052439145-WorkspaceCreatorFK.ts b/apps/server/src/database/migrations/1711052439145-WorkspaceCreatorFK.ts deleted file mode 100644 index ae994e5a..00000000 --- a/apps/server/src/database/migrations/1711052439145-WorkspaceCreatorFK.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class WorkspaceCreatorFK1711052439145 implements MigrationInterface { - name = 'WorkspaceCreatorFK1711052439145' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" ADD CONSTRAINT "UQ_2aab2dd12dc65eb183d99b953e0" UNIQUE ("creatorId")`); - await queryRunner.query(`ALTER TABLE "workspaces" ADD CONSTRAINT "FK_2aab2dd12dc65eb183d99b953e0" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "workspaces" DROP CONSTRAINT "FK_2aab2dd12dc65eb183d99b953e0"`); - await queryRunner.query(`ALTER TABLE "workspaces" DROP CONSTRAINT "UQ_2aab2dd12dc65eb183d99b953e0"`); - await queryRunner.query(`ALTER TABLE "spaces" RENAME COLUMN "visibility" TO "privacy"`); - } - -} diff --git a/apps/server/src/database/migrations/1711053025788-MakeSpaceCreatorIdNullable.ts b/apps/server/src/database/migrations/1711053025788-MakeSpaceCreatorIdNullable.ts deleted file mode 100644 index d00479a1..00000000 --- a/apps/server/src/database/migrations/1711053025788-MakeSpaceCreatorIdNullable.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class MakeSpaceCreatorIdNullable1711053025788 implements MigrationInterface { - name = 'MakeSpaceCreatorIdNullable1711053025788' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "spaces" DROP CONSTRAINT "FK_8469f60fb94d43a0280a83d0b35"`); - await queryRunner.query(`ALTER TABLE "spaces" ALTER COLUMN "creatorId" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "spaces" ADD CONSTRAINT "FK_8469f60fb94d43a0280a83d0b35" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "spaces" DROP CONSTRAINT "FK_8469f60fb94d43a0280a83d0b35"`); - await queryRunner.query(`ALTER TABLE "spaces" ALTER COLUMN "creatorId" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "spaces" ADD CONSTRAINT "FK_8469f60fb94d43a0280a83d0b35" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - -} diff --git a/apps/server/src/database/migrations/1711054895950-PolymorphicSpaceMembers.ts b/apps/server/src/database/migrations/1711054895950-PolymorphicSpaceMembers.ts deleted file mode 100644 index 50e0466a..00000000 --- a/apps/server/src/database/migrations/1711054895950-PolymorphicSpaceMembers.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class PolymorphicSpaceMembers1711054895950 implements MigrationInterface { - name = 'PolymorphicSpaceMembers1711054895950' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "space_members" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "userId" uuid, "groupId" uuid, "spaceId" uuid NOT NULL, "role" character varying(100) NOT NULL, "creatorId" uuid, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_07add45942b705c4b8c6c88013d" UNIQUE ("spaceId", "groupId"), CONSTRAINT "UQ_e91b442c5a1c7aa13c767c88363" UNIQUE ("spaceId", "userId"), CONSTRAINT "PK_5aaa6440d7f1e8b8c051df43d5e" PRIMARY KEY ("id"))`); - await queryRunner.query(`ALTER TABLE "space_members" ADD CONSTRAINT "FK_6b3b64db93d9a721ff7005eb6a3" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "space_members" ADD CONSTRAINT "FK_1677eab7e3f6602e13ca23418f5" FOREIGN KEY ("groupId") REFERENCES "groups"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "space_members" ADD CONSTRAINT "FK_25571cab1e221c0278499f4e801" FOREIGN KEY ("spaceId") REFERENCES "spaces"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "space_members" ADD CONSTRAINT "FK_63ce441685d52339875a4a33b7e" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "space_members" DROP CONSTRAINT "FK_63ce441685d52339875a4a33b7e"`); - await queryRunner.query(`ALTER TABLE "space_members" DROP CONSTRAINT "FK_25571cab1e221c0278499f4e801"`); - await queryRunner.query(`ALTER TABLE "space_members" DROP CONSTRAINT "FK_1677eab7e3f6602e13ca23418f5"`); - await queryRunner.query(`ALTER TABLE "space_members" DROP CONSTRAINT "FK_6b3b64db93d9a721ff7005eb6a3"`); - await queryRunner.query(`DROP TABLE "space_members"`); - } - -} diff --git a/apps/server/src/database/migrations/1711059108729-SpaceMemberEntityConstraint.ts b/apps/server/src/database/migrations/1711059108729-SpaceMemberEntityConstraint.ts deleted file mode 100644 index 8b716cff..00000000 --- a/apps/server/src/database/migrations/1711059108729-SpaceMemberEntityConstraint.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class SpaceMemberEntityConstraint1711059108729 implements MigrationInterface { - name = 'SpaceMemberEntityConstraint1711059108729' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "space_members" ADD CONSTRAINT "CHK_allow_userId_or_groupId" CHECK (("userId" IS NOT NULL AND "groupId" IS NULL) OR ("userId" IS NULL AND "groupId" IS NOT NULL))`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "space_members" DROP CONSTRAINT "CHK_allow_userId_or_groupId"`); - } - -}