|
| 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