40 lines
1,012 B
TypeScript
40 lines
1,012 B
TypeScript
import {
|
|
pgTable,
|
|
uuid,
|
|
text,
|
|
timestamp,
|
|
bigint,
|
|
} from "drizzle-orm/pg-core";
|
|
import { users } from "./users";
|
|
|
|
export const payments = pgTable("payments", {
|
|
id: uuid("id").defaultRandom().primaryKey(),
|
|
userId: uuid("user_id")
|
|
.notNull()
|
|
.references(() => users.id, { onDelete: "cascade" }),
|
|
|
|
// Stripe invoice ID
|
|
stripeInvoiceId: text("stripe_invoice_id").notNull().unique(),
|
|
|
|
// Amount in cents
|
|
amount: bigint("amount", { mode: "number" }).notNull(),
|
|
|
|
// Currency (USD, GBP, etc)
|
|
currency: text("currency").notNull(),
|
|
|
|
// Invoice status: "draft", "open", "paid", "void", "uncollectible"
|
|
status: text("status").notNull(),
|
|
|
|
// When the payment was made
|
|
paidAt: timestamp("paid_at", { withTimezone: true }),
|
|
|
|
// When the record was created
|
|
createdAt: timestamp("created_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
|
|
// When the record was updated
|
|
updatedAt: timestamp("updated_at", { withTimezone: true })
|
|
.notNull()
|
|
.defaultNow(),
|
|
});
|