import { index, integer, pgTable, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
import { agents } from "./agents.js";
import { documents } from "./documents.js";
import { organizations } from "./organizations.js";
export const documentRevisions = pgTable("document_revisions", {
    id: uuid("id").primaryKey().defaultRandom(),
    orgId: uuid("org_id").notNull().references(() => organizations.id),
    documentId: uuid("document_id").notNull().references(() => documents.id, { onDelete: "cascade" }),
    revisionNumber: integer("revision_number").notNull(),
    body: text("body").notNull(),
    changeSummary: text("change_summary"),
    createdByAgentId: uuid("created_by_agent_id").references(() => agents.id, { onDelete: "set null" }),
    createdByUserId: text("created_by_user_id"),
    createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
}, (table) => ({
    documentRevisionUq: uniqueIndex("document_revisions_document_revision_uq").on(table.documentId, table.revisionNumber),
    companyDocumentCreatedIdx: index("document_revisions_company_document_created_idx").on(table.orgId, table.documentId, table.createdAt),
}));
//# sourceMappingURL=document_revisions.js.map