feat: Consolidate user, role, and theme settings tables into a single migration file
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user