Fix external_ref migration failure on old databases

The schema initialization was trying to create an index on the external_ref
column before the migration that adds the column runs. This caused 'no such
column: external_ref' errors when opening very old databases (pre-0.17.5).

Solution: Move the index creation into the migration that adds the column.

Fixes #284

Amp-Thread-ID: https://ampcode.com/threads/T-2744d5a7-168f-4ef6-bcab-926db846de20
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-11-10 10:50:13 -08:00
parent 9e9db62954
commit 8be792a460
2 changed files with 7 additions and 1 deletions

View File

@@ -30,7 +30,7 @@ CREATE INDEX IF NOT EXISTS idx_issues_status ON issues(status);
CREATE INDEX IF NOT EXISTS idx_issues_priority ON issues(priority);
CREATE INDEX IF NOT EXISTS idx_issues_assignee ON issues(assignee);
CREATE INDEX IF NOT EXISTS idx_issues_created_at ON issues(created_at);
CREATE INDEX IF NOT EXISTS idx_issues_external_ref ON issues(external_ref);
-- Note: idx_issues_external_ref is created in migrations/002_external_ref_column.go
-- Dependencies table
CREATE TABLE IF NOT EXISTS dependencies (