import { index, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
import { agents } from "./agents.js";
import { issues } from "./issues.js";
import { organizations } from "./organizations.js";
export const issueComments = pgTable("issue_comments", {
    id: uuid("id").primaryKey().defaultRandom(),
    orgId: uuid("org_id").notNull().references(() => organizations.id),
    issueId: uuid("issue_id").notNull().references(() => issues.id),
    authorAgentId: uuid("author_agent_id").references(() => agents.id),
    authorUserId: text("author_user_id"),
    body: text("body").notNull(),
    deletedAt: timestamp("deleted_at", { withTimezone: true }),
    deletedByUserId: text("deleted_by_user_id"),
    createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
    updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
}, (table) => ({
    issueIdx: index("issue_comments_issue_idx").on(table.issueId),
    orgIdx: index("issue_comments_company_idx").on(table.orgId),
    orgIssueCreatedAtIdx: index("issue_comments_company_issue_created_at_idx").on(table.orgId, table.issueId, table.createdAt),
    orgIssueCreatedIdIdx: index("issue_comments_org_issue_created_id_idx").on(table.orgId, table.issueId, table.createdAt, table.id),
    orgAuthorIssueCreatedAtIdx: index("issue_comments_company_author_issue_created_at_idx").on(table.orgId, table.authorUserId, table.issueId, table.createdAt),
}));
//# sourceMappingURL=issue_comments.js.map