import sys
import os

# Add the parent directory of `app` to the Python path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

from app import create_app
from app.extensions import db
from app.models import Role

# Create an application context
app = create_app()

with app.app_context():
    db.create_all()
    # Define the roles you want to add
    roles = ['Super Admin', 'Company Admin', 'User']

    # Add roles to the database
    for role_name in roles:
        role = Role(name=role_name)
        db.session.add(role)

    db.session.commit()
    print("Roles have been created successfully.")
