chore(db): stop wiping databases with an older schema version
All installations are past schema version 2, so the one-time reset is gone; data is never deleted on start (demo mode still resets). user_version is kept for future migrations. Legal test uses an in-memory DB (cleanup race). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1df32ece92
commit
108d166990
5 files changed
+12
-25
No files matched your search
@@ -144,8 +144,9 @@ func TestVisibilityFollowsOrganizations(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOutdatedSchemaIsWiped(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "old.db")
|
||||
// Existing data must survive a restart, whatever user_version the database carries.
|
||||
func TestDataSurvivesRestart(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "keep.db")
|
||||
store, err := NewStore(path)
|
||||
if err != nil {
|
||||
t.Fatalf("NewStore failed: %v", err)
|
||||
@@ -159,8 +160,8 @@ func TestOutdatedSchemaIsWiped(t *testing.T) {
|
||||
t.Fatalf("reopen failed: %v", err)
|
||||
}
|
||||
defer store.Close()
|
||||
if n, _ := store.CountUsers(); n != 0 {
|
||||
t.Fatalf("outdated database should start empty, found %d users", n)
|
||||
if n, _ := store.CountUsers(); n != 1 {
|
||||
t.Fatalf("data must be kept on restart, found %d users", n)
|
||||
}
|
||||
var v int
|
||||
_ = store.db.QueryRow(`PRAGMA user_version`).Scan(&v)
|
||||
|
||||
Reference in new issue
Block a user