Skip to content

Commit 68619bd

Browse files
author
Benny Burkert
committed
feat: WIP prepare db migration (path fix)
1 parent 6da35de commit 68619bd

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

backend/src/domain/database/entities/prompt-category.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Column, Entity, PrimaryColumn } from 'typeorm';
2-
import { VisibilityType } from 'src/domain/prompt';
2+
import { VisibilityType } from '../../prompt';
33
import { schema } from '../typeorm.helper';
44

55
@Entity({ name: 'prompt-categories', schema })

backend/src/domain/database/entities/prompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Column, Entity, JoinTable, ManyToMany, PrimaryGeneratedColumn } from 'typeorm';
2-
import { VisibilityType } from 'src/domain/prompt';
2+
import { VisibilityType } from '../../prompt';
33
import { schema } from '../typeorm.helper';
44
import { PromptCategoryEntity } from './prompt-category';
55

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class AddPrompts1757081968480 implements MigrationInterface {
4+
name = 'AddPrompts1757081968480';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`CREATE TABLE "company_chat"."prompt-categories" ("label" character varying NOT NULL, "description" character varying NOT NULL, "creationDate" TIMESTAMP NOT NULL, "visibility" character varying NOT NULL, CONSTRAINT "PK_fcceccb98fc892cc5b3e40c1097" PRIMARY KEY ("label"))`,
9+
);
10+
await queryRunner.query(
11+
`CREATE TABLE "company_chat"."prompts" ("id" SERIAL NOT NULL, "title" character varying, "description" character varying, "content" character varying NOT NULL, "visibility" character varying NOT NULL, "raiting" integer, CONSTRAINT "PK_21f33798862975179e40b216a1d" PRIMARY KEY ("id"))`,
12+
);
13+
await queryRunner.query(
14+
`CREATE TABLE "company_chat"."prompts_categories_prompt-categories" ("promptsId" integer NOT NULL, "promptCategoriesLabel" character varying NOT NULL, CONSTRAINT "PK_645256b9fc1fe950d6f6e7c3003" PRIMARY KEY ("promptsId", "promptCategoriesLabel"))`,
15+
);
16+
await queryRunner.query(
17+
`CREATE INDEX "IDX_b38fb3b439a6eea0016e1d5906" ON "company_chat"."prompts_categories_prompt-categories" ("promptsId") `,
18+
);
19+
await queryRunner.query(
20+
`CREATE INDEX "IDX_6515aea8d350337de0804256c9" ON "company_chat"."prompts_categories_prompt-categories" ("promptCategoriesLabel") `,
21+
);
22+
await queryRunner.query(
23+
`ALTER TABLE "company_chat"."prompts_categories_prompt-categories" ADD CONSTRAINT "FK_b38fb3b439a6eea0016e1d5906a" FOREIGN KEY ("promptsId") REFERENCES "company_chat"."prompts"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
24+
);
25+
await queryRunner.query(
26+
`ALTER TABLE "company_chat"."prompts_categories_prompt-categories" ADD CONSTRAINT "FK_6515aea8d350337de0804256c98" FOREIGN KEY ("promptCategoriesLabel") REFERENCES "company_chat"."prompt-categories"("label") ON DELETE CASCADE ON UPDATE CASCADE`,
27+
);
28+
}
29+
30+
public async down(queryRunner: QueryRunner): Promise<void> {
31+
await queryRunner.query(
32+
`ALTER TABLE "company_chat"."prompts_categories_prompt-categories" DROP CONSTRAINT "FK_6515aea8d350337de0804256c98"`,
33+
);
34+
await queryRunner.query(
35+
`ALTER TABLE "company_chat"."prompts_categories_prompt-categories" DROP CONSTRAINT "FK_b38fb3b439a6eea0016e1d5906a"`,
36+
);
37+
await queryRunner.query(`DROP INDEX "company_chat"."IDX_6515aea8d350337de0804256c9"`);
38+
await queryRunner.query(`DROP INDEX "company_chat"."IDX_b38fb3b439a6eea0016e1d5906"`);
39+
await queryRunner.query(`DROP TABLE "company_chat"."prompts_categories_prompt-categories"`);
40+
await queryRunner.query(`DROP TABLE "company_chat"."prompts"`);
41+
await queryRunner.query(`DROP TABLE "company_chat"."prompt-categories"`);
42+
}
43+
}

0 commit comments

Comments
 (0)