feat(app): add the drift database with schema v1 - #179
Merged
Merged
Conversation
Generated code is committed and CI checks it is current, so a fresh checkout builds without a codegen step. TrackKey is ported unchanged because legacy import keys on it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
內容
M1 PR 5:drift 最小 schema 與
TrackKey(ADR 0010 §決定 1–3;.trellis/tasks/archive/2026-09/09-29-drift-schema/prd.md)。drift2.35 加sqlite33.6(build hooks),用NativeDatabase.createInBackground。sqlite3_flutter_libs,也沒用依賴它的drift_flutter。fmp.db,每次開啟都執行PRAGMA foreign_keys = ON。appearance_settings:單列,欄位為空表示沒設定過(ADR 0011)。installed_plugins。plugin_storage:外鍵ON DELETE CASCADE,刪插件時一併刪除。insertOnConflictUpdate,因為REPLACE會觸發 cascade,把 storage 一起刪掉。make-migrations存 v1 快照。schema_test比對程式碼的 schema 與最新快照,含「多一欄就失敗」的反例。*.g.dart提交進 repo,CI 檢查它是最新的。舊專案把產生碼 gitignore,新 worktree 因此常出現像原始碼錯誤的「missing getter」。TrackKey:照舊版原樣搬,寫死字面值測試。它是持久化格式,M5 匯入舊資料要靠它對上。isar/sqlite3 共存探針(phase2-plan §7,未合併程式碼)
isar_community3.3.2 與sqlite33.6.0 在兩個平台都能共存,各自讀寫成功:.so的 LOAD 段 p_align ≥ 0x4000,zipalign -c -P 16通過。.trellis/tasks/09-28-m1-skeleton-tracer/research/isar-sqlite3-coexistence.md:不需要 ADR 0010 的退路。Review 指南
.trellis/spec/app/data/index.md的 migration 步驟:runMigrationSteps、foreign_key_check、user_version,最後再開外鍵。onUpgrade包進交易,而且在交易外才寫user_version。檢查代理依 drift 原始碼修正了這段,才做得到「失敗整個回滾」。驗證
app/:dart analyze --fatal-infos、flutter analyze乾淨;flutter test:76 過、1 跳過(live);foreign_keys = ON會讓 4 個測試變紅;把install改成insertOrReplace會讓「更新保留 storage」變紅。userdata-dev\fmp.db,畫面正常;files/fmp.db。