from functions.database import Role, Permissao, RolePermissao, Base, engine
from sqlalchemy.orm import Session

def init_db():
    Base.metadata.create_all(engine)
    
    with Session(engine) as session:
        # Criar roles
        admin = Role(nome='Administrador', nivel=1)
        coord = Role(nome='Coordenador', nivel=2)
        milit = Role(nome='Militante', nivel=3)
        
        # Criar permissões
        perm_admin = Permissao(nome='admin', descricao='Acesso total')
        perm_militantes = Permissao(nome='ver_militantes', descricao='Ver militantes')
        # ... outras permissões ...
        
        session.add_all([admin, coord, milit, perm_admin, perm_militantes])
        session.commit()
        
        # Associar permissões aos roles
        session.add(RolePermissao(role=admin, permissao=perm_admin))
        session.add(RolePermissao(role=coord, permissao=perm_militantes))
        session.commit()

if __name__ == '__main__':
    init_db() 