Add issue identifiers, activity run tracking, and migration inspection
Add issuePrefix/issueCounter to companies and issueNumber/identifier to issues for human-readable issue IDs (e.g. PAP-42). Add runId to activity_log for linking activity to heartbeat runs. Rework DB client to support migration state inspection and interactive pending migration prompts at startup. Add reopen option to issue comments validator. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE "activity_log" ADD COLUMN "run_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "activity_log" ADD CONSTRAINT "activity_log_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "activity_log_run_id_idx" ON "activity_log" USING btree ("run_id");--> statement-breakpoint
|
||||
CREATE INDEX "activity_log_entity_type_id_idx" ON "activity_log" USING btree ("entity_type","entity_id");--> statement-breakpoint
|
||||
ALTER TABLE "agents" DROP COLUMN "context_mode";
|
||||
28
packages/db/src/migrations/0004_issue_identifiers.sql
Normal file
28
packages/db/src/migrations/0004_issue_identifiers.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
-- Add issue identifier columns to companies
|
||||
ALTER TABLE "companies" ADD COLUMN "issue_prefix" text NOT NULL DEFAULT 'PAP';--> statement-breakpoint
|
||||
ALTER TABLE "companies" ADD COLUMN "issue_counter" integer NOT NULL DEFAULT 0;--> statement-breakpoint
|
||||
|
||||
-- Add issue identifier columns to issues
|
||||
ALTER TABLE "issues" ADD COLUMN "issue_number" integer;--> statement-breakpoint
|
||||
ALTER TABLE "issues" ADD COLUMN "identifier" text;--> statement-breakpoint
|
||||
|
||||
-- Backfill existing issues: assign sequential issue_number per company ordered by created_at
|
||||
WITH numbered AS (
|
||||
SELECT id, company_id, ROW_NUMBER() OVER (PARTITION BY company_id ORDER BY created_at ASC) AS rn
|
||||
FROM issues
|
||||
)
|
||||
UPDATE issues
|
||||
SET issue_number = numbered.rn,
|
||||
identifier = (SELECT issue_prefix FROM companies WHERE companies.id = issues.company_id) || '-' || numbered.rn
|
||||
FROM numbered
|
||||
WHERE issues.id = numbered.id;--> statement-breakpoint
|
||||
|
||||
-- Sync each company's issue_counter to the max assigned number
|
||||
UPDATE companies
|
||||
SET issue_counter = COALESCE(
|
||||
(SELECT MAX(issue_number) FROM issues WHERE issues.company_id = companies.id),
|
||||
0
|
||||
);--> statement-breakpoint
|
||||
|
||||
-- Create unique index on (company_id, identifier)
|
||||
CREATE UNIQUE INDEX "issues_company_identifier_idx" ON "issues" USING btree ("company_id","identifier");
|
||||
2502
packages/db/src/migrations/meta/0003_snapshot.json
Normal file
2502
packages/db/src/migrations/meta/0003_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,20 @@
|
||||
"when": 1771349403162,
|
||||
"tag": "0002_big_zaladane",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 3,
|
||||
"version": "7",
|
||||
"when": 1771456737635,
|
||||
"tag": "0003_shallow_quentin_quire",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 4,
|
||||
"version": "7",
|
||||
"when": 1771545600000,
|
||||
"tag": "0004_issue_identifiers",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user