Spaces:
Sleeping
Sleeping
File size: 1,045 Bytes
7f81110 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import { pgTable, uuid, text, jsonb, timestamp, index } from "drizzle-orm/pg-core";
import { stores } from "../../../../../modules/shopify/infrastructure/postgres/schema/stores";
export const webhookEvents = pgTable("webhook_events", {
id: uuid("id").primaryKey().defaultRandom(),
storeId: uuid("store_id").notNull().references(() => stores.id, { onDelete: "cascade" }),
topic: text("topic").notNull(),
externalId: text("external_id").notNull(),
payload: jsonb("payload").notNull(),
status: text("status").notNull().default("pending"), // pending | processed | failed
error: text("error"),
processedAt: timestamp("processed_at"),
createdAt: timestamp("created_at").defaultNow().notNull(),
}, (t) => ({
storeIdx: index("idx_webhooks_store").on(t.storeId),
topicIdx: index("idx_webhooks_topic").on(t.topic),
extIdx: index("idx_webhooks_external").on(t.externalId),
}));
export type WebhookEvent = typeof webhookEvents.$inferSelect;
export type NewWebhookEvent = typeof webhookEvents.$inferInsert;
|