Skip to content

Commit

Permalink
fix: add piecetype to meta data
Browse files Browse the repository at this point in the history
  • Loading branch information
alerdenisov committed Dec 6, 2023
1 parent b976062 commit 9dce366
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/api/src/pieces/pieces.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ export class PiecesService {
name: 'ASC',
version: 'DESC',
} as const)
.getOne();
.getOne()
}
}
6 changes: 6 additions & 0 deletions libs/database/src/entities/piece.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions libs/database/src/migrations/1701893634169-pieces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class Pieces1701893634169 implements MigrationInterface {
name = 'Pieces1701893634169'

public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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"`);
}

}
3 changes: 2 additions & 1 deletion libs/database/src/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
export * from './1699113772938-secrets';
export * from './1701893634169-pieces';

0 comments on commit 9dce366

Please sign in to comment.