Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activations: add an enabled_at column #1145

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/gen-server/entity/Activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ export class Activation extends BaseEntity {
@Column({name: 'updated_at', default: () => "CURRENT_TIMESTAMP"})
public updatedAt: Date;

// When the enterprise activation was first enabled, so we know when
// to start counting the trial date.
//
// Activations are created at Grist installation to track other
// things such as prefs, but the user might not enable Enterprise
// until later.
@Column({name: 'enabled_at', type: nativeValues.dateTimeType, nullable: true})
public enabledAt: Date|null;
jordigh marked this conversation as resolved.
Show resolved Hide resolved

public checkProperties(props: any): props is Partial<InstallProperties> {
for (const key of Object.keys(props)) {
if (!installPropertyKeys.includes(key)) {
Expand Down
18 changes: 18 additions & 0 deletions app/gen-server/migration/1722529827161-Activation-Enabled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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<void> {
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,
}));
}

jordigh marked this conversation as resolved.
Show resolved Hide resolved
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropColumn('activations', 'enabled_at');
}
}
4 changes: 3 additions & 1 deletion test/gen-server/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import {Shares1701557445716 as Shares} from 'app/gen-server/migration/1701557445
import {Billing1711557445716 as BillingFeatures} from 'app/gen-server/migration/1711557445716-Billing';
import {UserLastConnection1713186031023
as UserLastConnection} from 'app/gen-server/migration/1713186031023-UserLastConnection';
import {ActivationEnabled1722529827161
as ActivationEnabled} from 'app/gen-server/migration/1722529827161-Activation-Enabled';

const home: HomeDBManager = new HomeDBManager();

Expand All @@ -53,7 +55,7 @@ const migrations = [Initial, Login, PinDocs, UserPicture, DisplayEmail, DisplayE
ExternalBilling, DocOptions, Secret, UserOptions, GracePeriodStart,
DocumentUsage, Activations, UserConnectId, UserUUID, UserUniqueRefUUID,
Forks, ForkIndexes, ActivationPrefs, AssistantLimit, Shares, BillingFeatures,
UserLastConnection];
UserLastConnection, ActivationEnabled];

// Assert that the "members" acl rule and group exist (or not).
function assertMembersGroup(org: Organization, exists: boolean) {
Expand Down
Loading