You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Documentation/Database-Upgrade-Strategy.md
+48-19Lines changed: 48 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@
10
10
11
11
Nine uses versioned SQLite database files (`app_vX.Y.0.db`) tied to the application's MAJOR.MINOR version. This document describes how the upgrade path works, the known failure mode for version-skipping users, the fix implemented in `app-database-upgrade`, and how to test all upgrade scenarios.
12
12
13
+
**This fix ships in v1.1.0** alongside the `app_v1.1.0.db` database file. The normal upgrade path (v1.0.0 → v1.1.0) is covered by `PreviousDatabaseFileName`. The version-skip fallback scan is active in every release from v1.1.0 onward — it protects against any skip at any version boundary (v1.0.0 → v1.2.0, v1.1.0 → v1.3.0, v1.2.0 → v2.0.0, etc.).
14
+
13
15
---
14
16
15
17
## Database Versioning Policy
@@ -50,31 +52,37 @@ Nine uses versioned SQLite database files (`app_vX.Y.0.db`) tied to the applicat
50
52
4. EF Core migrations apply the delta to `app_v1.1.0.db`
This scenario can occur at any version boundary. The earliest possible real-world instance is a user on v1.0.0 who skips v1.1.0 and installs v1.2.0 directly. The same logic handles v1.1.0 → v1.3.0, v1.2.0 → v2.0.0, v1.0.0 → v10.0.0, or any other gap.
4. EF Core creates **blank**`app_v2.0.0.db` — **user data is lost** ❌
73
+
4. EF Core creates **blank**`app_v1.2.0.db` — **user data is lost** ❌
68
74
69
-
**With the fix (implemented in `app-database-upgrade` branch):**
75
+
**With the fix (shipped in v1.1.0, present in every subsequent release):**
70
76
71
-
1. Target `app_v2.0.0.db` — not found
77
+
1. Target `app_v1.2.0.db` — not found
72
78
2.`PreviousDatabaseFileName` = `app_v1.1.0.db` — not found
73
79
3.**Fallback scan**: glob `app_v*.db` in the config directory, parse each filename as `System.Version`, pick the highest version that is **less than** the target
74
-
4. Finds `app_v1.0.0.db`, copies it to `app_v2.0.0.db`
75
-
5. EF Core migrations apply the **full delta** from v1.0.0 schema to v2.0.0 schema
80
+
4. Finds `app_v1.0.0.db`, copies it to `app_v1.2.0.db`
81
+
5. EF Core migrations apply the **full delta** from v1.0.0 schema to v1.2.0 schema
76
82
6. App starts with all user data intact ✅
77
83
84
+
The same logic handles multi-step skips (e.g. only `app_v1.0.0.db` present when installing v1.4.0) and double-digit versions (v9.x → v10.x) correctly via `System.Version` numeric comparison.
85
+
78
86
### Fresh install (no previous DB)
79
87
80
88
1. Target `app_vX.Y.0.db` — not found
@@ -203,20 +211,22 @@ All scenarios require a test user data directory. On Linux this is `~/.config/Ni
203
211
204
212
### Scenario 3: Version Skip (Missing Predecessor)
205
213
214
+
Simulates a user on v1.0.0 who skips v1.1.0 and installs v1.2.0 directly. This is the earliest possible real-world version-skip.
215
+
206
216
**Setup:**
207
217
208
218
1. Run Scenario 1 to create `app_v1.0.0.db` with real data
209
219
2. Do **not** create `app_v1.1.0.db`
210
-
3. Change `appsettings.json` to `DatabaseFileName: "app_v2.0.0.db"`, `PreviousDatabaseFileName: "app_v1.1.0.db"`
220
+
3. Change `appsettings.json` to `DatabaseFileName: "app_v1.2.0.db"`, `PreviousDatabaseFileName: "app_v1.1.0.db"`
Once merged to `development`, run a full build and Scenarios 1 and 5 against the actual `~/.config/Nine/` directory (with a real v1.0.0 DB backup) before merging to `main`.
311
+
**Version notes:**
312
+
313
+
-`PreviousDatabaseFileName` covers the direct one-step upgrade (v1.0.0 → v1.1.0, v1.1.0 → v1.2.0, etc.)
314
+
- The fallback scan covers **any skip at any version boundary** — v1.0.0 → v1.2.0, v1.1.0 → v1.3.0, v1.2.0 → v2.0.0, v1.0.0 → v10.0.0, etc.
315
+
- This protection is present in every release from v1.1.0 onward; there is no version at which it "becomes" relevant
316
+
- Run all 6 scenarios against `~/.config/Nine/` before merging to `main`
317
+
318
+
```
319
+
320
+
**Version notes:**
321
+
322
+
- v1.1.0 `PreviousDatabaseFileName` = `app_v1.0.0.db` — covers the direct v1.0.0 → v1.1.0 upgrade path (no skip possible yet, only one prior version exists)
323
+
- The fallback scan becomes the safety net for v1.2.0+ when a user could first skip a version
324
+
- Once merged to `development`, run Scenarios 1 and 5 against the actual `~/.config/Nine/` directory (with a real v1.0.0 DB backup) before merging to `main`
0 commit comments