from app.extensions import db

class CompanyModule(db.Model):
    __tablename__ = 'company_modules'

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

    company = db.relationship('Company', backref='company_module_list')
    module = db.relationship('Module', backref='company_assignments')

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