2023-07-05 15:36:45 +00:00
|
|
|
import {BaseEntity, Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn} from 'typeorm';
|
|
|
|
import {BillingAccount} from 'app/gen-server/entity/BillingAccount';
|
|
|
|
import {nativeValues} from 'app/gen-server/lib/values';
|
|
|
|
|
|
|
|
@Entity('limits')
|
|
|
|
export class Limit extends BaseEntity {
|
|
|
|
@PrimaryGeneratedColumn()
|
|
|
|
public id: number;
|
|
|
|
|
2023-07-12 13:57:02 +00:00
|
|
|
@Column({type: Number})
|
2023-07-05 15:36:45 +00:00
|
|
|
public limit: number;
|
|
|
|
|
2023-07-12 13:57:02 +00:00
|
|
|
@Column({type: Number})
|
2023-07-05 15:36:45 +00:00
|
|
|
public usage: number;
|
|
|
|
|
2023-07-12 13:57:02 +00:00
|
|
|
@Column({type: String})
|
2023-07-05 15:36:45 +00:00
|
|
|
public type: string;
|
|
|
|
|
2023-07-12 13:57:02 +00:00
|
|
|
@Column({name: 'billing_account_id', type: Number})
|
2023-07-05 15:36:45 +00:00
|
|
|
public billingAccountId: number;
|
|
|
|
|
|
|
|
@ManyToOne(type => BillingAccount)
|
|
|
|
@JoinColumn({name: 'billing_account_id'})
|
|
|
|
public billingAccount: BillingAccount;
|
|
|
|
|
2023-07-12 13:57:02 +00:00
|
|
|
@Column({name: 'created_at', type: nativeValues.dateTimeType, default: () => "CURRENT_TIMESTAMP"})
|
2023-07-05 15:36:45 +00:00
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Last time the Limit.limit value was changed, by an upgrade or downgrade. Null if it has never been changed.
|
|
|
|
*/
|
|
|
|
@Column({name: 'changed_at', type: nativeValues.dateTimeType, nullable: true})
|
|
|
|
public changedAt: Date|null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Last time the Limit.usage was used (by sending a request to the model). Null if it has never been used.
|
|
|
|
*/
|
|
|
|
@Column({name: 'used_at', type: nativeValues.dateTimeType, nullable: true})
|
|
|
|
public usedAt: Date|null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Last time the Limit.usage was reset, probably by billing cycle change. Null if it has never been reset.
|
|
|
|
*/
|
|
|
|
@Column({name: 'reset_at', type: nativeValues.dateTimeType, nullable: true})
|
|
|
|
public resetAt: Date|null;
|
|
|
|
}
|