Fix foreign key constraint error on MySQL

(cherry picked from commit 2a9108f90482a6be86d0b8af4dfcc30f6651ff28)
This commit is contained in:
Thomas M Steenholdt 2018-06-06 11:59:15 -02:00
parent a4af4ad4b3
commit 2b3b67a3af

View File

@ -486,7 +486,7 @@ class Account(db.Model):
""" """
account = Account.query.filter(Account.name == account_name).first() account = Account.query.filter(Account.name == account_name).first()
if account is None: if account is None:
return 0 return None
return account.id return account.id
@ -664,7 +664,7 @@ class Domain(db.Model):
notified_serial = db.Column(db.Integer) notified_serial = db.Column(db.Integer)
last_check = db.Column(db.Integer) last_check = db.Column(db.Integer)
dnssec = db.Column(db.Integer) dnssec = db.Column(db.Integer)
account_id = db.Column(db.Integer, db.ForeignKey('account.id'), nullable = False) account_id = db.Column(db.Integer, db.ForeignKey('account.id'))
account = db.relationship("Account", back_populates="domains") account = db.relationship("Account", back_populates="domains")
settings = db.relationship('DomainSetting', back_populates='domain') settings = db.relationship('DomainSetting', back_populates='domain')