De DB-tabel `public.todos` was buiten de migratie-historie om gedropt,
terwijl `prisma/schema.prisma` `model Todo` en migration_lock.toml geen
removal-migratie kenden. Gevolg: drift tussen schema (Todo aanwezig) en
DB (tabel weg) — runtime-fout op alle `prisma.todo.*`-calls in
`actions/todos.ts`, `app/api/todos/route.ts`, `app/(app)/todos/page.tsx`,
`app/api/products/[id]/claude-context/route.ts` en MCP-tool create_todo.
Deze migratie zet de tabel exact terug zoals het schema 'm beschrijft —
gegenereerd via:
npx prisma migrate diff --from-config-datasource \
--to-schema prisma/schema.prisma --script
CREATE TABLE todos + 2 indexes + 2 foreign keys naar users (CASCADE) en
products (SET NULL).
Eerdere data is niet hersteld (geen backup-stap); de tabel is leeg. Dat
is acceptabel: Todo's waren lichtgewicht notities zonder kritische data
en de removal-Idea staat nog gepland (zie #128 → re-plan met de
Make-Plan-prompt-update uit #130). Tot dat moment werken de Todo-flows
weer.
Verified locally: prisma migrate status (up to date), lint, typecheck,
tests 564/564, next build.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
1.3 KiB
SQL
33 lines
1.3 KiB
SQL
-- Restore todos table after out-of-band drop.
|
|
-- DB-state lost the table while schema.prisma still defined `model Todo` and
|
|
-- migration history showed no removal. This migration brings DB back in sync
|
|
-- with the schema. Generated via:
|
|
-- npx prisma migrate diff --from-config-datasource \
|
|
-- --to-schema prisma/schema.prisma --script
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "todos" (
|
|
"id" TEXT NOT NULL,
|
|
"user_id" TEXT NOT NULL,
|
|
"product_id" TEXT,
|
|
"title" TEXT NOT NULL,
|
|
"description" VARCHAR(2000),
|
|
"done" BOOLEAN NOT NULL DEFAULT false,
|
|
"archived" BOOLEAN NOT NULL DEFAULT false,
|
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updated_at" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "todos_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "todos_user_id_done_archived_idx" ON "todos"("user_id", "done", "archived");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "todos_user_id_product_id_idx" ON "todos"("user_id", "product_id");
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "todos" ADD CONSTRAINT "todos_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
-- AddForeignKey
|
|
ALTER TABLE "todos" ADD CONSTRAINT "todos_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "products"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|