Преглед изворни кода

feat(app.entity): add exposed and domain fields

Nicolas Meienberger пре 2 година
родитељ
комит
015e168634

+ 22 - 0
packages/system-api/src/config/migrations/1662036689477-AppExposedDomain.ts

@@ -0,0 +1,22 @@
+import { MigrationInterface, QueryRunner } from 'typeorm';
+
+export class AppExposedDomain1662036689477 implements MigrationInterface {
+  name = 'AppExposedDomain1662036689477';
+
+  public async up(queryRunner: QueryRunner): Promise<void> {
+    await queryRunner.query('ALTER TABLE "app" ADD "exposed" boolean DEFAULT false');
+    // populate all apps with exposed to false
+    await queryRunner.query('UPDATE "app" SET "exposed" = false');
+    // add NOT NULL constraint
+    await queryRunner.query('ALTER TABLE "app" ALTER COLUMN "exposed" SET NOT NULL');
+
+    await queryRunner.query('ALTER TABLE "app" ADD "domain" character varying');
+    await queryRunner.query('ALTER TABLE "app" ALTER COLUMN "version" SET DEFAULT \'1\'');
+  }
+
+  public async down(queryRunner: QueryRunner): Promise<void> {
+    await queryRunner.query('ALTER TABLE "app" ALTER COLUMN "version" SET DEFAULT \'0\'');
+    await queryRunner.query('ALTER TABLE "app" DROP COLUMN "domain"');
+    await queryRunner.query('ALTER TABLE "app" DROP COLUMN "exposed"');
+  }
+}

+ 8 - 0
packages/system-api/src/modules/apps/app.entity.ts

@@ -55,6 +55,14 @@ class App extends BaseEntity {
   @UpdateDateColumn()
   updatedAt!: Date;
 
+  @Field(() => Boolean)
+  @Column({ type: 'boolean', default: false, nullable: false })
+  exposed!: boolean;
+
+  @Field(() => String)
+  @Column({ type: 'varchar', nullable: true })
+  domain?: string;
+
   @Field(() => AppInfo, { nullable: true })
   info(): AppInfo | null {
     return getAppInfo(this.id);