fix: preserve schema 15 compatibility for v0.1.8

This commit is contained in:
2026-10-17 18:27:53 +09:00
parent a97548c36b
commit 1134f058cc
61 changed files with 2650 additions and 644 deletions
+14 -13
View File
@@ -14,33 +14,34 @@ def tables(path):
return {r[0] for r in conn.execute("select name from sqlite_master where type='table'")}
def test_fresh_and_repeated_init_never_create_manual_assets(tmp_path):
def test_fresh_and_repeated_init_retain_manual_assets(tmp_path):
path = str(tmp_path / "fresh.sqlite3")
init_db(path)
init_db(path)
assert "manual_assets" not in tables(path)
assert "manual_assets" in tables(path)
def test_existing_legacy_manual_assets_is_dropped_without_other_row_loss(tmp_path):
def test_existing_legacy_manual_assets_is_preserved_without_other_row_loss(tmp_path):
path = str(tmp_path / "legacy.sqlite3")
init_db(path)
with sqlite3.connect(path) as conn:
conn.execute("create table manual_assets (id text primary key, name text)")
conn.execute("insert into manual_assets values ('old', 'legacy')")
conn.execute("insert into manual_assets (id,name,created_at,updated_at) values ('old', 'legacy','t','t')")
conn.execute("insert into accounts (id,name,type,active,created_at,updated_at) values ('a','Keep','bank',1,'t','t')")
conn.commit()
init_db(path)
with sqlite3.connect(path) as conn:
assert conn.execute("select count(*) from accounts where id='a'").fetchone()[0] == 1
assert "manual_assets" not in tables(path)
assert conn.execute("select name from manual_assets where id='old'").fetchone() == ("legacy",)
assert "manual_assets" in tables(path)
def test_manual_asset_public_operations_are_unsupported(tmp_path):
path = str(tmp_path / "unsupported.sqlite3")
def test_manual_asset_public_operations_are_supported(tmp_path):
path = str(tmp_path / "supported.sqlite3")
init_db(path)
expected = {"success": False, "error_code": "unsupported", "error": "manual assets are no longer supported"}
assert create_manual_asset("Emergency", 100, "2026-09-30", "cash", db_path=path) == expected
assert list_manual_assets(db_path=path) == expected
created = create_manual_asset("Emergency", 100, "2026-09-30", "cash", db_path=path)
listed = list_manual_assets(db_path=path)
assert created["success"] and listed["success"]
assert listed["manual_assets"][0]["id"] == created["manual_asset"]["id"]
def test_account_real_estate_creation_and_snapshot_preview_use_normal_path(tmp_path):
@@ -55,7 +56,7 @@ def test_account_real_estate_creation_and_snapshot_preview_use_normal_path(tmp_p
assert preview_asset_snapshot_close("2026-09-30", db_path=path)["success"] is True
def test_manual_assets_absent_after_initialization_with_existing_accounts(tmp_path):
def test_manual_assets_present_after_initialization_with_existing_accounts(tmp_path):
path = str(tmp_path / "accounts.sqlite3")
init_db(path)
with sqlite3.connect(path) as conn:
@@ -63,4 +64,4 @@ def test_manual_assets_absent_after_initialization_with_existing_accounts(tmp_pa
init_db(path)
with sqlite3.connect(path) as conn:
assert conn.execute("select count(*) from accounts").fetchone()[0] == before
assert "manual_assets" not in tables(path)
assert "manual_assets" in tables(path)