Added onupdate="CASCADE" to the foreign keys.
This commit is contained in:
parent
dde9c38bb8
commit
d648538fbb
@ -69,8 +69,10 @@ class BaseAccountL10n(db.Model):
|
|||||||
"""A localized base account title."""
|
"""A localized base account title."""
|
||||||
__tablename__ = "accounting_base_accounts_l10n"
|
__tablename__ = "accounting_base_accounts_l10n"
|
||||||
"""The table name."""
|
"""The table name."""
|
||||||
account_code = db.Column(db.String, db.ForeignKey(BaseAccount.code,
|
account_code = db.Column(db.String,
|
||||||
ondelete="CASCADE"),
|
db.ForeignKey(BaseAccount.code,
|
||||||
|
onupdate="CASCADE",
|
||||||
|
ondelete="CASCADE"),
|
||||||
nullable=False, primary_key=True)
|
nullable=False, primary_key=True)
|
||||||
"""The code of the account."""
|
"""The code of the account."""
|
||||||
account = db.relationship(BaseAccount, back_populates="l10n")
|
account = db.relationship(BaseAccount, back_populates="l10n")
|
||||||
@ -88,8 +90,9 @@ class Account(db.Model):
|
|||||||
id = db.Column(db.Integer, nullable=False, primary_key=True,
|
id = db.Column(db.Integer, nullable=False, primary_key=True,
|
||||||
autoincrement=False)
|
autoincrement=False)
|
||||||
"""The account ID."""
|
"""The account ID."""
|
||||||
base_code = db.Column(db.String, db.ForeignKey(BaseAccount.code,
|
base_code = db.Column(db.String,
|
||||||
ondelete="CASCADE"),
|
db.ForeignKey(BaseAccount.code, onupdate="CASCADE",
|
||||||
|
ondelete="CASCADE"),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
"""The code of the base account."""
|
"""The code of the base account."""
|
||||||
base = db.relationship(BaseAccount, back_populates="accounts")
|
base = db.relationship(BaseAccount, back_populates="accounts")
|
||||||
@ -103,7 +106,9 @@ class Account(db.Model):
|
|||||||
created_at = db.Column(db.DateTime(timezone=True), nullable=False,
|
created_at = db.Column(db.DateTime(timezone=True), nullable=False,
|
||||||
server_default=db.func.now())
|
server_default=db.func.now())
|
||||||
"""The time of creation."""
|
"""The time of creation."""
|
||||||
created_by_id = db.Column(db.Integer, db.ForeignKey(user_pk_column),
|
created_by_id = db.Column(db.Integer,
|
||||||
|
db.ForeignKey(user_pk_column,
|
||||||
|
onupdate="CASCADE"),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
"""The ID of the creator."""
|
"""The ID of the creator."""
|
||||||
created_by = db.relationship(user_cls, foreign_keys=created_by_id)
|
created_by = db.relationship(user_cls, foreign_keys=created_by_id)
|
||||||
@ -111,7 +116,9 @@ class Account(db.Model):
|
|||||||
updated_at = db.Column(db.DateTime(timezone=True), nullable=False,
|
updated_at = db.Column(db.DateTime(timezone=True), nullable=False,
|
||||||
server_default=db.func.now())
|
server_default=db.func.now())
|
||||||
"""The time of last update."""
|
"""The time of last update."""
|
||||||
updated_by_id = db.Column(db.Integer, db.ForeignKey(user_pk_column),
|
updated_by_id = db.Column(db.Integer,
|
||||||
|
db.ForeignKey(user_pk_column,
|
||||||
|
onupdate="CASCADE"),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
"""The ID of the updator."""
|
"""The ID of the updator."""
|
||||||
updated_by = db.relationship(user_cls, foreign_keys=updated_by_id)
|
updated_by = db.relationship(user_cls, foreign_keys=updated_by_id)
|
||||||
@ -299,8 +306,9 @@ class Account(db.Model):
|
|||||||
class AccountL10n(db.Model):
|
class AccountL10n(db.Model):
|
||||||
"""A localized account title."""
|
"""A localized account title."""
|
||||||
__tablename__ = "accounting_accounts_l10n"
|
__tablename__ = "accounting_accounts_l10n"
|
||||||
account_id = db.Column(db.Integer, db.ForeignKey(Account.id,
|
account_id = db.Column(db.Integer,
|
||||||
ondelete="CASCADE"),
|
db.ForeignKey(Account.id, onupdate="CASCADE",
|
||||||
|
ondelete="CASCADE"),
|
||||||
nullable=False, primary_key=True)
|
nullable=False, primary_key=True)
|
||||||
account = db.relationship(Account, back_populates="l10n")
|
account = db.relationship(Account, back_populates="l10n")
|
||||||
locale = db.Column(db.String, nullable=False, primary_key=True)
|
locale = db.Column(db.String, nullable=False, primary_key=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user