Initial commit - Migrated to Dev environment
This commit is contained in:
37
backend/app/final_admin_fix.py
Executable file
37
backend/app/final_admin_fix.py
Executable file
@@ -0,0 +1,37 @@
|
||||
import asyncio
|
||||
from sqlalchemy import text
|
||||
from app.db.session import SessionLocal, engine
|
||||
from app.models.user import User, UserRole
|
||||
from app.core.security import get_password_hash
|
||||
|
||||
async def run_fix():
|
||||
async with SessionLocal() as db:
|
||||
# 1. Ellenőrizzük az oszlopokat (biztonsági játék)
|
||||
res = await db.execute(text("SELECT column_name FROM information_schema.columns WHERE table_schema = \u0027data\u0027 AND table_name = \u0027users\u0027"))
|
||||
cols = [r[0] for r in res.fetchall()]
|
||||
print(f"INFO: Meglévő oszlopok: {cols}")
|
||||
|
||||
if "hashed_password" not in cols:
|
||||
print("❌ HIBA: A hashed_password oszlop még mindig hiányzik! A migráció nem volt sikeres.")
|
||||
return
|
||||
|
||||
# 2. Admin létrehozása
|
||||
res = await db.execute(text("SELECT id FROM data.users WHERE email = :e"), {"e": "admin@profibot.hu"})
|
||||
if res.fetchone():
|
||||
print("⚠ Az admin@profibot.hu már létezik.")
|
||||
else:
|
||||
admin = User(
|
||||
email="admin@profibot.hu",
|
||||
hashed_password=get_password_hash("Admin123!"),
|
||||
first_name="Admin",
|
||||
last_name="Profibot",
|
||||
role=UserRole.ADMIN,
|
||||
is_superuser=True,
|
||||
is_active=True
|
||||
)
|
||||
db.add(admin)
|
||||
await db.commit()
|
||||
print("✅ SIKER: Admin felhasználó létrehozva!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run_fix())
|
||||
Reference in New Issue
Block a user