code quality run
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import logging
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
from sqlalchemy import text
|
||||
from .logging import setup_logging
|
||||
from .database import engine, SessionLocal
|
||||
from models.database_models import Base
|
||||
import logging
|
||||
|
||||
from middleware.auth import AuthManager
|
||||
from models.database_models import Base
|
||||
|
||||
from .database import SessionLocal, engine
|
||||
from .logging import setup_logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
auth_manager = AuthManager()
|
||||
@@ -44,15 +47,29 @@ def create_indexes():
|
||||
with engine.connect() as conn:
|
||||
try:
|
||||
# User indexes
|
||||
conn.execute(text("CREATE INDEX IF NOT EXISTS idx_user_email ON users(email)"))
|
||||
conn.execute(text("CREATE INDEX IF NOT EXISTS idx_user_username ON users(username)"))
|
||||
conn.execute(
|
||||
text("CREATE INDEX IF NOT EXISTS idx_user_email ON users(email)")
|
||||
)
|
||||
conn.execute(
|
||||
text("CREATE INDEX IF NOT EXISTS idx_user_username ON users(username)")
|
||||
)
|
||||
|
||||
# Product indexes
|
||||
conn.execute(text("CREATE INDEX IF NOT EXISTS idx_product_gtin ON products(gtin)"))
|
||||
conn.execute(text("CREATE INDEX IF NOT EXISTS idx_product_marketplace ON products(marketplace)"))
|
||||
conn.execute(
|
||||
text("CREATE INDEX IF NOT EXISTS idx_product_gtin ON products(gtin)")
|
||||
)
|
||||
conn.execute(
|
||||
text(
|
||||
"CREATE INDEX IF NOT EXISTS idx_product_marketplace ON products(marketplace)"
|
||||
)
|
||||
)
|
||||
|
||||
# Stock indexes
|
||||
conn.execute(text("CREATE INDEX IF NOT EXISTS idx_stock_gtin_location ON stock(gtin, location)"))
|
||||
conn.execute(
|
||||
text(
|
||||
"CREATE INDEX IF NOT EXISTS idx_stock_gtin_location ON stock(gtin, location)"
|
||||
)
|
||||
)
|
||||
|
||||
conn.commit()
|
||||
logger.info("Database indexes created successfully")
|
||||
|
||||
Reference in New Issue
Block a user