Initial commit - Migrated to Dev environment
This commit is contained in:
1
code-server-config/data/User/History/-16684355/entries.json
Executable file
1
code-server-config/data/User/History/-16684355/entries.json
Executable file
@@ -0,0 +1 @@
|
||||
{"version":1,"resource":"vscode-remote://192.168.100.43:8443/home/coder/project/backend/create_dummy_employee.py","entries":[{"id":"toEt.py","timestamp":1768944627792}]}
|
||||
42
code-server-config/data/User/History/-16684355/toEt.py
Executable file
42
code-server-config/data/User/History/-16684355/toEt.py
Executable file
@@ -0,0 +1,42 @@
|
||||
import asyncio
|
||||
import os
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
from sqlalchemy import text
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
raw_url = os.getenv("DATABASE_URL")
|
||||
if not raw_url:
|
||||
raw_url = "postgresql://admin:PASSWORD_111@postgres-db:5432/service_finder"
|
||||
DATABASE_URL = raw_url.replace("postgresql://", "postgresql+asyncpg://").replace("/service_finder_db", "/service_finder")
|
||||
|
||||
async def hire_driver():
|
||||
engine = create_async_engine(DATABASE_URL)
|
||||
|
||||
async with engine.begin() as conn:
|
||||
print("👤 Kovács János (User ID: 2) létrehozása...")
|
||||
# Létrehozzuk a User-t
|
||||
await conn.execute(text("""
|
||||
INSERT INTO data.users (id, email, password_hash, role, country, default_currency, is_active)
|
||||
VALUES (2, 'sofor@ceg.hu', 'hash123', 'PRIVATE', 'HU', 'HUF', TRUE)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
"""))
|
||||
|
||||
# Frissítjük a sorrendet
|
||||
await conn.execute(text("SELECT setval('data.users_id_seq', (SELECT MAX(id) FROM data.users));"))
|
||||
|
||||
print("🤝 Hozzárendelés a Te cégedhez (ID: 1)...")
|
||||
# Betesszük a fleet_members táblába
|
||||
await conn.execute(text("""
|
||||
INSERT INTO data.fleet_members (user_id, owner_id, role)
|
||||
VALUES (2, 1, 'DRIVER')
|
||||
ON CONFLICT (user_id, owner_id) DO NOTHING;
|
||||
"""))
|
||||
|
||||
print("✅ KÉSZ! Kovács János mostantól a csapatod tagja.")
|
||||
await engine.dispose()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(hire_driver())
|
||||
|
||||
Reference in New Issue
Block a user