28 lines
774 B
Python
28 lines
774 B
Python
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")
|