from app.extensions import db

class UserModulePermission(db.Model):
    __tablename__ = 'user_module_permissions'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
    module_id = db.Column(db.Integer, db.ForeignKey('modules.id'), nullable=False)
    aktiv = db.Column(db.Boolean, default=True)

    user = db.relationship('User', backref='user_module_list')
    module = db.relationship('Module', backref='user_assignments')

    __table_args__ = (db.UniqueConstraint('user_id', 'module_id'),)
