From 9dce366b9ef5b82acae45ebb709bcee1f4f2a3cc Mon Sep 17 00:00:00 2001 From: Aler Denisov Date: Wed, 6 Dec 2023 21:14:44 +0100 Subject: [PATCH] fix: add piecetype to meta data --- apps/api/src/pieces/pieces.service.ts | 2 +- libs/database/src/entities/piece.entity.ts | 6 ++++++ .../src/migrations/1701893634169-pieces.ts | 20 +++++++++++++++++++ libs/database/src/migrations/index.ts | 3 ++- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 libs/database/src/migrations/1701893634169-pieces.ts diff --git a/apps/api/src/pieces/pieces.service.ts b/apps/api/src/pieces/pieces.service.ts index d80de83..bf9047f 100644 --- a/apps/api/src/pieces/pieces.service.ts +++ b/apps/api/src/pieces/pieces.service.ts @@ -100,6 +100,6 @@ export class PiecesService { name: 'ASC', version: 'DESC', } as const) - .getOne(); + .getOne() } } diff --git a/libs/database/src/entities/piece.entity.ts b/libs/database/src/entities/piece.entity.ts index 267f94e..be190b1 100644 --- a/libs/database/src/entities/piece.entity.ts +++ b/libs/database/src/entities/piece.entity.ts @@ -39,6 +39,12 @@ export class Piece extends MetaEntity { @Column({ type: 'jsonb', nullable: false }) triggers: Object; + + @Column({ type: 'enum', enum: ['OFFICIAL', 'COMMUNITY'], nullable: false, default: "OFFICIAL" }) + pieceType: 'OFFICIAL' | 'COMMUNITY'; + + @Column({ type: 'enum', enum: ['REGISTRY', 'LOCAL'], nullable: false, default: "REGISTRY" }) + packageType: 'REGISTRY' | 'LOCAL'; } @CustomRepository(Piece) diff --git a/libs/database/src/migrations/1701893634169-pieces.ts b/libs/database/src/migrations/1701893634169-pieces.ts new file mode 100644 index 0000000..f04e3b9 --- /dev/null +++ b/libs/database/src/migrations/1701893634169-pieces.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class Pieces1701893634169 implements MigrationInterface { + name = 'Pieces1701893634169' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TYPE "public"."piece_piecetype_enum" AS ENUM('OFFICIAL', 'COMMUNITY')`); + await queryRunner.query(`ALTER TABLE "piece" ADD "pieceType" "public"."piece_piecetype_enum" NOT NULL DEFAULT 'OFFICIAL'`); + await queryRunner.query(`CREATE TYPE "public"."piece_packagetype_enum" AS ENUM('REGISTRY', 'LOCAL')`); + await queryRunner.query(`ALTER TABLE "piece" ADD "packageType" "public"."piece_packagetype_enum" NOT NULL DEFAULT 'REGISTRY'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "piece" DROP COLUMN "packageType"`); + await queryRunner.query(`DROP TYPE "public"."piece_packagetype_enum"`); + await queryRunner.query(`ALTER TABLE "piece" DROP COLUMN "pieceType"`); + await queryRunner.query(`DROP TYPE "public"."piece_piecetype_enum"`); + } + +} diff --git a/libs/database/src/migrations/index.ts b/libs/database/src/migrations/index.ts index f80e563..1e6799c 100644 --- a/libs/database/src/migrations/index.ts +++ b/libs/database/src/migrations/index.ts @@ -17,4 +17,5 @@ export * from './1692121464935-pieces'; export * from './1697435937767-user-google'; export * from './1697737348969-email'; export * from './1697743613593-roles'; -export * from './1699113772938-secrets'; \ No newline at end of file +export * from './1699113772938-secrets'; +export * from './1701893634169-pieces'; \ No newline at end of file