feat: Consolidate user, role, and theme settings tables into a single migration file
Some checks failed
Run Tests / e2e tests (push) Failing after 3s
Run Tests / lint tests (push) Failing after 1m30s
Run Tests / unit tests (push) Failing after 1m32s

This commit is contained in:
2025-10-27 14:56:37 +01:00
parent e37488bcf6
commit b1d50a56e0
6 changed files with 38 additions and 55 deletions

View File

@@ -22,6 +22,7 @@ connection string; this script will still honor the granular inputs above.
"""
from __future__ import annotations
from config.database import Base
import argparse
import importlib
import logging
@@ -43,7 +44,6 @@ from sqlalchemy import create_engine, inspect
ROOT_DIR = Path(__file__).resolve().parents[1]
if str(ROOT_DIR) not in sys.path:
sys.path.insert(0, str(ROOT_DIR))
from config.database import Base
logger = logging.getLogger(__name__)
@@ -126,7 +126,8 @@ class DatabaseConfig:
]
if missing:
raise RuntimeError(
"Missing required database configuration: " + ", ".join(missing)
"Missing required database configuration: " +
", ".join(missing)
)
host = cast(str, host)
@@ -340,7 +341,8 @@ class DatabaseSetup:
rollback_label = f"drop database {self.config.database}"
self._register_rollback(
rollback_label,
lambda db=self.config.database: self._drop_database(db),
lambda db=self.config.database: self._drop_database(
db),
)
logger.info("Created database '%s'", self.config.database)
finally:
@@ -409,7 +411,8 @@ class DatabaseSetup:
rollback_label = f"drop role {self.config.user}"
self._register_rollback(
rollback_label,
lambda role=self.config.user: self._drop_role(role),
lambda role=self.config.user: self._drop_role(
role),
)
else:
logger.info("Role '%s' already present", self.config.user)
@@ -839,6 +842,7 @@ class DatabaseSetup:
seed_args = argparse.Namespace(
currencies=True,
units=True,
theme=True,
defaults=False,
dry_run=dry_run,
verbose=0,