-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpaymentLogs.ts
More file actions
46 lines (41 loc) · 1.27 KB
/
paymentLogs.ts
File metadata and controls
46 lines (41 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {
pgTable,
uuid,
text,
jsonb,
decimal,
timestamp,
unique,
} from "drizzle-orm/pg-core";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import { createdAndUpdatedAtFields } from "./shared";
const paymentPlatforms = ["mercadopago", "stripe"] as const;
// TAG—COMMUNITY
export const paymentLogsSchema = pgTable(
"payments_logs",
{
id: uuid("id").primaryKey().defaultRandom(),
externalId: text("external_id").notNull(),
externalProductReference: text("external_product_reference"),
platform: text("platform", {
enum: paymentPlatforms,
}).notNull(),
transactionAmount: decimal("transaction_amount").notNull(),
externalCreationDate: timestamp("external_creation_date", {
mode: "date",
precision: 6,
withTimezone: true,
}),
currencyId: text("currency_id").notNull(),
originalResponseBlob: jsonb("original_response_blob").default({
payment_status: "pending",
status: "pending",
}),
...createdAndUpdatedAtFields,
},
(t) => ({
unique_platform_identifier: unique().on(t.externalId, t.platform),
}),
);
export const selectPaymentLogsSchema = createSelectSchema(paymentLogsSchema);
export const insertPaymentLogsSchema = createInsertSchema(paymentLogsSchema);