sync: migrate secure-online-shop to Gitea (2026-08-10)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from app.core.config import get_settings
|
||||
from app.db.seed_demo import seed_demo_products
|
||||
from app.db.session import engine
|
||||
from app.models import Base
|
||||
|
||||
logger = logging.getLogger("app.db")
|
||||
|
||||
|
||||
def initialize_database() -> None:
|
||||
Base.metadata.create_all(bind=engine)
|
||||
logger.info("Database tables created successfully")
|
||||
settings = get_settings()
|
||||
if settings.demo_seed_products:
|
||||
from app.db.session import SessionLocal
|
||||
|
||||
with SessionLocal() as db:
|
||||
seed_demo_products(db, settings.demo_product_count)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
initialize_database()
|
||||
print("Database initialized successfully.")
|
||||
print("To create a shop account, run: python -m app.db.create_shop_account")
|
||||
Reference in New Issue
Block a user