# Import the database object to interact with our SQLite database
from app.extensions import db

# Create a blueprint (model) for the roles (like Admin, Verifier, Finance, Volunteer)
class Role(db.Model):

    # Explicitly set the actual name of the table in the database
    __tablename__ = 'roles'

    # Primary Key: A unique ID number for every role (e.g., 1, 2, 3)
    id = db.Column(db.Integer, primary_key=True)

    # Role Name: The name of the role (e.g., 'Admin'). It must be unique and cannot be empty.
    role_name = db.Column(db.String(50), unique=True, nullable=False)

    @property
    def name(self) -> str:
        """Convenience property alias to support standard role.name access."""
        return self.role_name

    def __repr__(self) -> str:
        """String representation of the Role instance."""
        return f"<Role {self.role_name}>"