mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 16:07:35 +01:00
Same schema-drift pattern as 0005/0006: Drizzle schema declared user_projects.org_id (uuid → orgs.id, on delete set null) but no migration shipped it. Every SELECT through Drizzle requested the column, so the query crashed on production, ensureUserProjectEntityLinks landed in its .catch returning [], and /api/control reported trackedProjectCount=0 despite 20 active user_projects rows for the logged-in user. With the column in place, /api/control now returns all 20 project cards — the autonomous loop (outcome streak, sleep mode, dispatch reasoner, beacon countdown) finally has a surface to render against. Applied to the live Neon DB; verified via the production /api/control endpoint returning 20 projects with full dirPath linkage. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
14 lines
673 B
SQL
14 lines
673 B
SQL
-- Schema drift fix: src/db/schema/user-projects.ts declared org_id
|
|
-- (uuid → orgs.id, on delete set null) but no migration shipped it.
|
|
-- Every SELECT through Drizzle requests the column, so the query failed
|
|
-- on production, ensureUserProjectEntityLinks() landed in its .catch
|
|
-- returning [], and /api/control reported trackedProjectCount=0 — the
|
|
-- control panel rendered zero cards for the only signed-in user despite
|
|
-- 12 active user_projects rows in the DB.
|
|
|
|
ALTER TABLE "user_projects"
|
|
ADD COLUMN IF NOT EXISTS "org_id" uuid REFERENCES "orgs"("id") ON DELETE SET NULL;
|
|
|
|
CREATE INDEX IF NOT EXISTS "idx_user_projects_org_id"
|
|
ON "user_projects" ("org_id");
|