"""Seed initial data into the database."""

import sys
import os

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from app.database import SessionLocal
from app.models.user import AllowedDomain


def seed() -> None:
    db = SessionLocal()
    try:
        existing = db.query(AllowedDomain).filter_by(domain="dak.de").first()
        if not existing:
            db.add(AllowedDomain(domain="dak.de", role="dak_mitarbeiter"))
            db.commit()
            print("Seeded: dak.de domain whitelist")
        else:
            print("Already exists: dak.de domain whitelist")
    finally:
        db.close()


if __name__ == "__main__":
    seed()
