Restructure into full project layout
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from sqlalchemy import select
|
||||
from app.core.database import AsyncSessionLocal
|
||||
from app.core.security import hash_password
|
||||
from app.core.config import settings
|
||||
from app.models.user import User, UserRole
|
||||
|
||||
|
||||
async def bootstrap_admin():
|
||||
async with AsyncSessionLocal() as db:
|
||||
result = await db.execute(select(User).where(User.email == settings.ADMIN_EMAIL))
|
||||
if result.scalar_one_or_none():
|
||||
return
|
||||
|
||||
admin = User(
|
||||
email=settings.ADMIN_EMAIL,
|
||||
hashed_password=hash_password(settings.ADMIN_PASSWORD),
|
||||
display_name="Admin",
|
||||
role=UserRole.ADMIN,
|
||||
is_active=True,
|
||||
)
|
||||
db.add(admin)
|
||||
await db.commit()
|
||||
print(f"Admin user created: {settings.ADMIN_EMAIL}")
|
||||
Reference in New Issue
Block a user