Add cascade deletion of jobs and corpora on user delete.

This commit is contained in:
Stephan Porada 2019-08-15 15:57:27 +02:00
parent bccf661957
commit 388efbbd73

View File

@ -113,8 +113,10 @@ class User(UserMixin, db.Model):
role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
username = db.Column(db.String(64), unique=True, index=True)
# Relationships
corpora = db.relationship('Corpus', backref='creator', lazy='dynamic')
jobs = db.relationship('Job', backref='creator', lazy='dynamic')
corpora = db.relationship('Corpus', backref='creator', lazy='dynamic',
cascade='save-update, merge, delete')
jobs = db.relationship('Job', backref='creator', lazy='dynamic',
cascade='save-update, merge, delete')
def __repr__(self):
"""