[PR #382] [MERGED] fix: auto-migrate lorebook folders on startup #4598

Closed
opened 2026-10-22 04:09:02 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/382
Author: @TheLonelyDevil9
Created: 5/3/2026
Status: ✅ Merged
Merged: 5/3/2026
Merged by: @TheLonelyDevil9

Base: main ← Head: codex/fix-lorebook-folder-startup-migration


📝 Commits (2)

  • 5ef0357 fix: auto-migrate lorebook folders on startup
  • ba485d2 test: preserve legacy lorebook rows during migration

📊 Changes

3 files changed (+194 additions, -0 deletions)

View changed files

➕ AGENTS.md (+65 -0)
📝 packages/server/src/db/migrate.ts (+20 -0)
➕ packages/server/test/db-migrations.test.ts (+109 -0)

📄 Description

Summary

  • Add missing startup migration support for the lorebook_folders table.
  • Add the missing lorebook_entries.folder_id startup migration for existing installs.
  • Add a regression test that simulates upgrading a pre-folder lorebook database and verifies legacy rows survive both migration runs.
  • Include the repo AGENTS.md maintainer instructions.

Why

Existing installs can hit no such table: lorebook_folders after updating, which breaks lorebook UI/API flows unless users manually run database commands. This makes the migration seamless during normal app startup.

Linked Issue

No linked issue exists yet. Per CONTRIBUTING.md, one should be opened before this PR is submitted/merged; this PR is based on live user reports of upgraded installs failing with no such table: lorebook_folders.

Test Plan

  • Review the startup migration SQL for parity with the Drizzle schema.
  • Manually verify an existing install with lorebooks starts without no such table: lorebook_folders.
  • Manually verify pre-existing lorebook entries remain visible after upgrade.
  • Manually verify creating, toggling, reordering, and deleting lorebook folders in browser.

Manual Verification Notes

Manual app/browser verification is still needed before merge. Recommended flow: start from an install/database created before lorebook folders existed, update to this branch, launch normally, open the lorebooks panel, confirm existing entries render, then create/toggle/delete a folder and refresh.

Automated Validation Run Locally

  • pnpm --filter @marinara-engine/server exec tsx --test test/db-migrations.test.ts
  • Disposable DB schema check: drizzle-kit push --force against a throwaway SQLite file
  • pnpm check

Summary by CodeRabbit

  • Tests

    • Added a migration test ensuring startup migrations create new folder structures and safely run twice on existing databases
  • Chores

    • Updated database schema to add lorebook folder support and a folder identifier for entries
    • Added contributor guidance documenting workflow, validation steps, PR hygiene, and logging conventions

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/382 **Author:** [@TheLonelyDevil9](https://github.com/TheLonelyDevil9) **Created:** 5/3/2026 **Status:** ✅ Merged **Merged:** 5/3/2026 **Merged by:** [@TheLonelyDevil9](https://github.com/TheLonelyDevil9) **Base:** `main` ← **Head:** `codex/fix-lorebook-folder-startup-migration` --- ### 📝 Commits (2) - [`5ef0357`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5ef035773c77827a2189dbc5457e925aaf569afb) fix: auto-migrate lorebook folders on startup - [`ba485d2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ba485d2466cefea445b8b428bf19192635f21d8a) test: preserve legacy lorebook rows during migration ### 📊 Changes **3 files changed** (+194 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `AGENTS.md` (+65 -0) 📝 `packages/server/src/db/migrate.ts` (+20 -0) ➕ `packages/server/test/db-migrations.test.ts` (+109 -0) </details> ### 📄 Description ## Summary - Add missing startup migration support for the `lorebook_folders` table. - Add the missing `lorebook_entries.folder_id` startup migration for existing installs. - Add a regression test that simulates upgrading a pre-folder lorebook database and verifies legacy rows survive both migration runs. - Include the repo `AGENTS.md` maintainer instructions. ## Why Existing installs can hit `no such table: lorebook_folders` after updating, which breaks lorebook UI/API flows unless users manually run database commands. This makes the migration seamless during normal app startup. ## Linked Issue No linked issue exists yet. Per `CONTRIBUTING.md`, one should be opened before this PR is submitted/merged; this PR is based on live user reports of upgraded installs failing with `no such table: lorebook_folders`. ## Test Plan - [ ] Review the startup migration SQL for parity with the Drizzle schema. - [ ] Manually verify an existing install with lorebooks starts without `no such table: lorebook_folders`. - [ ] Manually verify pre-existing lorebook entries remain visible after upgrade. - [ ] Manually verify creating, toggling, reordering, and deleting lorebook folders in browser. ## Manual Verification Notes Manual app/browser verification is still needed before merge. Recommended flow: start from an install/database created before lorebook folders existed, update to this branch, launch normally, open the lorebooks panel, confirm existing entries render, then create/toggle/delete a folder and refresh. ## Automated Validation Run Locally - `pnpm --filter @marinara-engine/server exec tsx --test test/db-migrations.test.ts` - Disposable DB schema check: `drizzle-kit push --force` against a throwaway SQLite file - `pnpm check` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Added a migration test ensuring startup migrations create new folder structures and safely run twice on existing databases * **Chores** * Updated database schema to add lorebook folder support and a folder identifier for entries * Added contributor guidance documenting workflow, validation steps, PR hygiene, and logging conventions <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:09:02 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4598
No description provided.