mirror of
https://github.com/docmost/docmost.git
synced 2025-11-10 07:12:04 +10:00
fix migrations
This commit is contained in:
@ -1,14 +0,0 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class PageChildren1696635925309 implements MigrationInterface {
|
||||
name = 'PageChildren1696635925309'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "pages" ADD "children" uuid array NOT NULL DEFAULT '{}'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "children"`);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddPageOrderToWorkspace1696699967408 implements MigrationInterface {
|
||||
name = 'AddPageOrderToWorkspace1696699967408'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "workspaces" ADD "pageOrder" uuid array NOT NULL DEFAULT '{}'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "workspaces" DROP COLUMN "pageOrder"`);
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,7 +4,7 @@ export class PageOrdering1697150118968 implements MigrationInterface {
|
||||
name = 'PageOrdering1697150118968'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
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`);
|
||||
}
|
||||
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddDefaultToChildrenIds1697314563977 implements MigrationInterface {
|
||||
name = 'AddDefaultToChildrenIds1697314563977'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
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<void> {
|
||||
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"`);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class FixPageOrdering1697314976326 implements MigrationInterface {
|
||||
name = 'FixPageOrdering1697314976326'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" SET DEFAULT ARRAY[]::uuid[]`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "page_ordering" ALTER COLUMN "childrenIds" SET DEFAULT ARRAY[]::uuid[]`);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class FixPageOrderingNext1697316172733 implements MigrationInterface {
|
||||
name = 'FixPageOrderingNext1697316172733'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "pages" DROP COLUMN "children"`);
|
||||
await queryRunner.query(`ALTER TABLE "workspaces" DROP COLUMN "pageOrder"`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
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 '{}'`);
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,7 +5,6 @@ export class Comments1698947225315 implements MigrationInterface {
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
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"`);
|
||||
}
|
||||
|
||||
|
||||
@ -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`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,13 +5,11 @@ export class AddLastUpdatedByIdToPage1699745066813 implements MigrationInterface
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
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<void> {
|
||||
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"`);
|
||||
}
|
||||
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddTsvectorColumn1706450034470 implements MigrationInterface {
|
||||
name = 'AddTsvectorColumn1706450034470'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
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<void> {
|
||||
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"`);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user