/** * App-side schema barrel. Exports the framework's substrate tables and is the * place to declare app-specific tables. The drizzle-kit config in * `drizzle.config.ts` points at this file, so any table declared here gets * generated into a migration when you run `pnpm db:generate`, and `db/index.ts` * binds it to the database client, which binds no tables of its own. */ import { createPostgresSchema } from "@raredays/postgres/schema"; import siteSpec from "../site.spec.ts"; // The substrate tables, with organization_id typed from idStrategy in // site.spec.ts (framework ADR-0028). export const { webhookDeliveries, jobExecutionStatus, jobExecutions, jobDedupMarkers } = createPostgresSchema(siteSpec.idStrategy); // Declare app-specific tables here. Use the column helpers from // @raredays/core/schema so every table stays multi-tenancy-ready and types its // user and organization ids from idStrategy in site.spec.ts (framework // ADR-0028). Framework modules export a schema factory built the same way, // e.g. `export const { customers, subscriptions, subscriptionEvents } = // createBillingSchema(siteSpec.idStrategy);` from @raredays/billing/schema. // Example: // // import { pgTable, text, uuid } from "drizzle-orm/pg-core"; // import { idColumn, tenantColumns, timestampColumns } from "@raredays/core/schema"; // // export const widgets = pgTable("widgets", { // id: uuid("id").primaryKey().defaultRandom(), // ...tenantColumns(siteSpec.idStrategy), // ...timestampColumns(), // ownerId: idColumn(siteSpec.idStrategy, "user_id").notNull(), // name: text("name").notNull(), // });