chore: add invoice and subscription entities

This commit is contained in:
mahyargdz
2025-02-08 15:27:32 +03:30
parent ffa2a2a806
commit e4f201bea2
16 changed files with 181 additions and 10 deletions
@@ -0,0 +1,23 @@
import { Column, Entity, ManyToOne } from "typeorm";
import { SubscriptionPlan } from "./subscription.entity";
import { BaseEntity } from "../../../common/entities/base.entity";
import { User } from "../../users/entities/user.entity";
@Entity()
export class UserSubscription extends BaseEntity {
@ManyToOne(() => User, (user) => user.subscriptions, { nullable: false, onDelete: "CASCADE" })
user: User;
@ManyToOne(() => SubscriptionPlan, { nullable: false, onDelete: "CASCADE" })
plan: SubscriptionPlan;
@Column({ type: "timestamp", nullable: false }) // When the subscription started
startDate: Date;
@Column({ type: "timestamp", nullable: false }) // When it expires
endDate: Date;
@Column({ type: "boolean", default: false }) // Whether the user canceled it
isCanceled: boolean;
}