Skip to content

Commit

Permalink
Add new billing columns for tenants (#68)
Browse files Browse the repository at this point in the history
* Add new migration for billing

* Add new billing columns for model Tenant

* Change column name in model

* Change column
  • Loading branch information
Sergey-weber authored Feb 2, 2024
1 parent 9bfac40 commit 23e983a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/db/models/new/tenant/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Model} from '../../..';
import {BillingRate} from './types';

export const TenantColumn = {
TenantId: 'tenantId',
Expand All @@ -10,6 +11,10 @@ export const TenantColumn = {
RetriesCount: 'retriesCount',
FoldersEnabled: 'foldersEnabled',
CollectionsEnabled: 'collectionsEnabled',
BillingRate: 'billingRate',
BillingAccountId: 'billingAccountId',
BillingInstanceServiceId: 'billingInstanceServiceId',
BillingStartedAt: 'billingStartedAt',
} as const;

export class Tenant extends Model {
Expand All @@ -30,4 +35,8 @@ export class Tenant extends Model {
[TenantColumn.RetriesCount]!: number;
[TenantColumn.FoldersEnabled]!: boolean;
[TenantColumn.CollectionsEnabled]!: boolean;
[TenantColumn.BillingRate]!: BillingRate;
[TenantColumn.BillingAccountId]!: Nullable<string>;
[TenantColumn.BillingInstanceServiceId]!: Nullable<string>;
[TenantColumn.BillingStartedAt]!: Nullable<string>;
}
4 changes: 4 additions & 0 deletions src/db/models/new/tenant/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum BillingRate {
Community = 'community',
Business = 'business',
}
10 changes: 9 additions & 1 deletion src/db/presentations/joined-migration-tenant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const selectedTenantColumns = [
TenantColumn.RetriesCount,
TenantColumn.CollectionsEnabled,
TenantColumn.FoldersEnabled,
TenantColumn.BillingRate,
TenantColumn.BillingAccountId,
TenantColumn.BillingInstanceServiceId,
TenantColumn.BillingStartedAt,
] as const;

const selectedMigrationTenantColumns = [
Expand All @@ -32,6 +36,10 @@ export const JoinedMigrationTenantColumn = {
RetriesCount: TenantColumn.RetriesCount,
CollectionsEnabled: TenantColumn.CollectionsEnabled,
FoldersEnabled: TenantColumn.FoldersEnabled,
BillingRate: TenantColumn.BillingRate,
BillingAccountId: TenantColumn.BillingAccountId,
BillingInstanceServiceId: TenantColumn.BillingInstanceServiceId,
BillingStartedAt: TenantColumn.BillingStartedAt,
FromId: MigrationTenantColumn.FromId,
ToId: MigrationTenantColumn.ToId,
Migrating: MigrationTenantColumn.Migrating,
Expand All @@ -58,7 +66,7 @@ export const joinMigrationTenant =
);
};

type SelectedTenantColumns = Pick<Tenant, ArrayElement<typeof selectedTenantColumns>>;
export type SelectedTenantColumns = Pick<Tenant, ArrayElement<typeof selectedTenantColumns>>;

type SelectedMigrationTenantColumns = Pick<
MigrationTenant,
Expand Down

0 comments on commit 23e983a

Please sign in to comment.