比如:
class User(Model):
roles = relationship('Role', secondary='users_roles', backref=db.backref('users'))
users_roles = db.Table(
'users_roles',
reference_col('users', ondelete='CASCADE', name='user_id'),
reference_col('roles', ondelete='CASCADE', name='role_id')
)
有没有办法在删除 role 的时候检测是否有 user 关联,有的话就报异常,无法删除。