delete now uses orphan cascade deletion instead of manual delete

This commit is contained in:
2020-05-27 20:56:23 +02:00
parent 120931dc4c
commit 722db5feae
2 changed files with 5 additions and 5 deletions

View File

@ -14,9 +14,9 @@ class User(UserMixin, db.Model):
email = db.Column(db.String(120), index=True, unique=True)
profile_pic = db.Column(db.String(256))
password_hash = db.Column(db.String(128))
google_token = db.relationship('GoogleToken', uselist=False, backref = 'user')
calendars = db.relationship('Calendar', backref='user', lazy=True)
devices = db.relationship('Device', backref='user')
google_token = db.relationship('GoogleToken', uselist=False, backref = 'user', cascade="all, delete-orphan")
calendars = db.relationship('Calendar', backref='user', lazy=True, cascade="all, delete-orphan")
devices = db.relationship('Device', backref='user', cascade="all, delete-orphan")
def __repr__(self):
return '<User {}>'.format(self.username)