Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
import { sql } from "drizzle-orm";
import { boolean, pgTable, text } from "drizzle-orm/pg-core";
import { organization } from "./better-auth-schema";
// See src/db/pg/app.schema.ts for why timestamps are ISO-8601 UTC text.
const isoNow = sql`to_char(now() AT TIME ZONE 'utc', 'YYYY-MM-DD"T"HH24:MI:SS.MS"Z"')`;
export const billingCustomerStatus = pgTable("billing_customer_status", {
organizationId: text("organization_id")
.primaryKey()
.references(() => organization.id, { onDelete: "cascade" }),
isPaying: boolean("is_paying").notNull().default(false),
paidPlanId: text("paid_plan_id"),
paidPlanStatus: text("paid_plan_status"),
// Full Autumn customer payload — escape hatch for any field we don't flatten,
// queryable via json_extract so we never have to widen this table.
customerJson: text("customer_json").notNull(),
syncedAt: text("synced_at").notNull(),
createdAt: text("created_at").notNull().default(isoNow),
updatedAt: text("updated_at").notNull().default(isoNow),
});