import { index, pgTable, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
import { assets } from "./assets.js";
import { issueComments } from "./issue_comments.js";
import { issues } from "./issues.js";
import { organizations } from "./organizations.js";
export const issueAttachments = pgTable("issue_attachments", {
    id: uuid("id").primaryKey().defaultRandom(),
    orgId: uuid("org_id").notNull().references(() => organizations.id),
    issueId: uuid("issue_id").notNull().references(() => issues.id, { onDelete: "cascade" }),
    assetId: uuid("asset_id").notNull().references(() => assets.id, { onDelete: "cascade" }),
    issueCommentId: uuid("issue_comment_id").references(() => issueComments.id, { onDelete: "set null" }),
    usage: text("usage").notNull().default("issue"),
    createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
    updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
}, (table) => ({
    companyIssueIdx: index("issue_attachments_company_issue_idx").on(table.orgId, table.issueId),
    issueCommentIdx: index("issue_attachments_issue_comment_idx").on(table.issueCommentId),
    usageIdx: index("issue_attachments_usage_idx").on(table.usage),
    assetUq: uniqueIndex("issue_attachments_asset_uq").on(table.assetId),
}));
//# sourceMappingURL=issue_attachments.js.map