From d087298f6ffcbc9faab85f098f1322ca0b36fc91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Guti=C3=A9rrez=20Hermoso?= Date: Thu, 1 Aug 2024 12:59:51 -0400 Subject: [PATCH] Activations: add an enabled_at column For #1140, I considered trying to use the existing fields in a better way, but because we already use the activations table to store preferences, we need to keep all of the existing data and its usage as-is. The enterprise code will use this new column to decide how long the trial period should be. --- app/gen-server/entity/Activation.ts | 3 +++ .../1722529827161-Activation-Enabled.ts | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 app/gen-server/migration/1722529827161-Activation-Enabled.ts diff --git a/app/gen-server/entity/Activation.ts b/app/gen-server/entity/Activation.ts index ca84c3f793..9bdaccf501 100644 --- a/app/gen-server/entity/Activation.ts +++ b/app/gen-server/entity/Activation.ts @@ -22,6 +22,9 @@ export class Activation extends BaseEntity { @Column({name: 'updated_at', default: () => "CURRENT_TIMESTAMP"}) public updatedAt: Date; + @Column({name: 'enabled_at', nullable: true}) + public enabledAt: Date|null; + public checkProperties(props: any): props is Partial { for (const key of Object.keys(props)) { if (!installPropertyKeys.includes(key)) { diff --git a/app/gen-server/migration/1722529827161-Activation-Enabled.ts b/app/gen-server/migration/1722529827161-Activation-Enabled.ts new file mode 100644 index 0000000000..011d1ba30e --- /dev/null +++ b/app/gen-server/migration/1722529827161-Activation-Enabled.ts @@ -0,0 +1,19 @@ +import * as sqlUtils from "app/gen-server/sqlUtils"; +import { MigrationInterface, QueryRunner, TableColumn } from "typeorm" + +export class ActivationEnabled1722529827161 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + const dbType = queryRunner.connection.driver.options.type; + const datetime = sqlUtils.datetime(dbType); + await queryRunner.addColumn('activations', new TableColumn({ + name: 'enabled_at', + type: datetime, + isNullable: true, + })); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropColumn('activations', 'enabled_at'); + } +}