Move app settings schema into SQL migration
This commit is contained in:
parent
2092f66dcd
commit
1d5126c2f8
4 changed files with 74 additions and 28 deletions
|
|
@ -15,6 +15,7 @@ from repub.model import (
|
|||
load_max_concurrent_jobs,
|
||||
resolve_database_path,
|
||||
save_setting,
|
||||
schema_paths,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -71,6 +72,39 @@ def test_initialize_database_bootstraps_schema_from_sql_files(tmp_path: Path) ->
|
|||
connection.close()
|
||||
|
||||
|
||||
def test_initialize_database_applies_newer_sql_files_to_existing_databases(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
db_path = tmp_path / "existing.db"
|
||||
connection = sqlite3.connect(db_path)
|
||||
try:
|
||||
connection.executescript(schema_paths()[0].read_text(encoding="utf-8"))
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
initialize_database(db_path)
|
||||
|
||||
connection = sqlite3.connect(db_path)
|
||||
try:
|
||||
table_names = {
|
||||
row[0]
|
||||
for row in connection.execute(
|
||||
"""
|
||||
SELECT name
|
||||
FROM sqlite_master
|
||||
WHERE type = 'table' AND name NOT LIKE 'sqlite_%'
|
||||
"""
|
||||
)
|
||||
}
|
||||
assert "app_setting" in table_names
|
||||
|
||||
job_columns = {row[1] for row in connection.execute("PRAGMA table_info('job')")}
|
||||
assert "convert_images" in job_columns
|
||||
assert "convert_video" in job_columns
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
|
||||
def test_initialize_database_configures_sqlite_pragmas(tmp_path: Path) -> None:
|
||||
db_path = tmp_path / "pragmas.db"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue