Add agent_config_revisions table for tracking agent configuration changes with rollback support. Add issue_approvals junction table linking issues to approvals. New migrations (0005, 0006) for permissions column and new tables. Rework migration client with statement-level idempotency checks (table/column/index/constraint existence) so migrations can be safely retried against partially-migrated databases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
24 lines
1.1 KiB
TypeScript
24 lines
1.1 KiB
TypeScript
import { pgTable, uuid, text, timestamp, index, primaryKey } from "drizzle-orm/pg-core";
|
|
import { companies } from "./companies.js";
|
|
import { issues } from "./issues.js";
|
|
import { approvals } from "./approvals.js";
|
|
import { agents } from "./agents.js";
|
|
|
|
export const issueApprovals = pgTable(
|
|
"issue_approvals",
|
|
{
|
|
companyId: uuid("company_id").notNull().references(() => companies.id),
|
|
issueId: uuid("issue_id").notNull().references(() => issues.id, { onDelete: "cascade" }),
|
|
approvalId: uuid("approval_id").notNull().references(() => approvals.id, { onDelete: "cascade" }),
|
|
linkedByAgentId: uuid("linked_by_agent_id").references(() => agents.id, { onDelete: "set null" }),
|
|
linkedByUserId: text("linked_by_user_id"),
|
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
},
|
|
(table) => ({
|
|
pk: primaryKey({ columns: [table.issueId, table.approvalId], name: "issue_approvals_pk" }),
|
|
issueIdx: index("issue_approvals_issue_idx").on(table.issueId),
|
|
approvalIdx: index("issue_approvals_approval_idx").on(table.approvalId),
|
|
companyIdx: index("issue_approvals_company_idx").on(table.companyId),
|
|
}),
|
|
);
|