← back to Ventura Claw
app/db/schema.ts
84 lines
import { pgTable, serial, text, timestamp, jsonb, boolean, integer } from "drizzle-orm/pg-core";
export const users = pgTable("users", {
id: serial("id").primaryKey(),
email: text("email").notNull().unique(),
name: text("name"),
role: text("role").notNull().default("user"),
createdAt: timestamp("created_at").defaultNow()
});
export const connectorAccounts = pgTable("connector_accounts", {
id: serial("id").primaryKey(),
userId: integer("user_id").references(() => users.id),
connector: text("connector").notNull(),
status: text("status").notNull().default("disconnected"),
scopes: jsonb("scopes"),
authJson: jsonb("auth_json"),
lastSyncAt: timestamp("last_sync_at"),
createdAt: timestamp("created_at").defaultNow()
});
export const approvalRequests = pgTable("approval_requests", {
id: serial("id").primaryKey(),
userId: integer("user_id").references(() => users.id),
connector: text("connector").notNull(),
action: text("action").notNull(),
payload: jsonb("payload").notNull(),
status: text("status").notNull().default("pending"),
decidedBy: integer("decided_by"),
decidedAt: timestamp("decided_at"),
createdAt: timestamp("created_at").defaultNow()
});
export const auditLogs = pgTable("audit_logs", {
id: serial("id").primaryKey(),
userId: integer("user_id"),
connector: text("connector"),
action: text("action").notNull(),
payload: jsonb("payload"),
result: jsonb("result"),
ok: boolean("ok").notNull().default(true),
ts: timestamp("ts").defaultNow()
});
export const workflows = pgTable("workflows", {
id: serial("id").primaryKey(),
ownerId: integer("owner_id").references(() => users.id),
name: text("name").notNull(),
graph: jsonb("graph").notNull(),
active: boolean("active").default(false),
createdAt: timestamp("created_at").defaultNow()
});
export const socialPosts = pgTable("social_posts", {
id: serial("id").primaryKey(),
userId: integer("user_id").references(() => users.id),
campaign: text("campaign"),
perPlatform: jsonb("per_platform").notNull(),
status: text("status").notNull().default("draft"),
scheduledAt: timestamp("scheduled_at"),
createdAt: timestamp("created_at").defaultNow()
});
export const paymentActions = pgTable("payment_actions", {
id: serial("id").primaryKey(),
userId: integer("user_id").references(() => users.id),
connector: text("connector").notNull(),
kind: text("kind").notNull(),
amountCents: integer("amount_cents"),
currency: text("currency").default("usd"),
status: text("status").notNull().default("pending_approval"),
raw: jsonb("raw"),
createdAt: timestamp("created_at").defaultNow()
});
export const mcpServers = pgTable("mcp_servers", {
id: serial("id").primaryKey(),
connector: text("connector").notNull().unique(),
command: text("command"),
args: jsonb("args"),
env: jsonb("env"),
enabled: boolean("enabled").default(false)
});