✅ admin side for now | 🔄 started FE
This commit is contained in:
@@ -104,45 +104,6 @@ export const paymentInfo = pgTable("payment_info", {
|
||||
updatedAt: timestamp("updated_at").defaultNow(),
|
||||
});
|
||||
|
||||
export const coupon = pgTable("coupon", {
|
||||
id: serial("id").primaryKey(),
|
||||
code: varchar("code", { length: 32 }).notNull().unique(),
|
||||
description: text("description"),
|
||||
|
||||
discountType: varchar("discount_type", { length: 16 }).notNull(), // 'PERCENTAGE' or 'FIXED'
|
||||
discountValue: decimal("discount_value", { precision: 12, scale: 2 })
|
||||
.$type<string>()
|
||||
.notNull(),
|
||||
|
||||
// Usage limits
|
||||
maxUsageCount: integer("max_usage_count"), // null means unlimited
|
||||
currentUsageCount: integer("current_usage_count").default(0).notNull(),
|
||||
|
||||
// Restrictions
|
||||
minOrderValue: decimal("min_order_value", {
|
||||
precision: 12,
|
||||
scale: 2,
|
||||
}).$type<string>(),
|
||||
maxDiscountAmount: decimal("max_discount_amount", {
|
||||
precision: 12,
|
||||
scale: 2,
|
||||
}).$type<string>(),
|
||||
|
||||
// Validity period
|
||||
startDate: timestamp("start_date").notNull(),
|
||||
endDate: timestamp("end_date"),
|
||||
|
||||
// Status
|
||||
isActive: boolean("is_active").default(true).notNull(),
|
||||
|
||||
// Tracking
|
||||
createdAt: timestamp("created_at").defaultNow(),
|
||||
updatedAt: timestamp("updated_at").defaultNow(),
|
||||
createdBy: text("created_by").references(() => user.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
});
|
||||
|
||||
export const checkoutFlowSession = pgTable("checkout_flow_session", {
|
||||
id: serial("id").primaryKey(),
|
||||
flowId: text("flow_id").unique().notNull(),
|
||||
@@ -200,10 +161,3 @@ export const orderRelations = relations(order, ({ one }) => ({
|
||||
references: [paymentInfo.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const couponRelations = relations(coupon, ({ one }) => ({
|
||||
createdByUser: one(user, {
|
||||
fields: [coupon.createdBy],
|
||||
references: [user.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user