Skip to content

Commit

Permalink
issue #105 - fix TxnReconcile model so model matches migrations - fro…
Browse files Browse the repository at this point in the history
…m f136418fc4ab and 5446559aecf7 we ended up with an index in the migrations but not the model
  • Loading branch information
jantman committed Feb 23, 2018
1 parent fd06b00 commit 26e307e
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions biweeklybudget/models/txn_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@

from biweeklybudget.utils import dtnow
from sqlalchemy import (
Column, Integer, String, ForeignKey, ForeignKeyConstraint, UniqueConstraint
Column, Integer, String, ForeignKey, ForeignKeyConstraint, UniqueConstraint,
Index
)
from sqlalchemy_utc import UtcDateTime
from sqlalchemy.orm import relationship, backref
Expand All @@ -47,15 +48,7 @@
class TxnReconcile(Base, ModelAsDict):

__tablename__ = 'txn_reconciles'
__table_args__ = (
ForeignKeyConstraint(
['ofx_account_id', 'ofx_fitid'],
['ofx_trans.account_id', 'ofx_trans.fitid']
),
UniqueConstraint('txn_id'),
UniqueConstraint('ofx_account_id', 'ofx_fitid'),
{'mysql_engine': 'InnoDB'}
)
# NOTE: __table_args__ is after column definitions

#: Primary Key
id = Column(Integer, primary_key=True)
Expand Down Expand Up @@ -94,6 +87,25 @@ class TxnReconcile(Base, ModelAsDict):
#: time when this reconcile was made
reconciled_at = Column(UtcDateTime, default=dtnow())

__table_args__ = (
ForeignKeyConstraint(
['ofx_account_id', 'ofx_fitid'],
['ofx_trans.account_id', 'ofx_trans.fitid']
),
UniqueConstraint('txn_id'),
UniqueConstraint('ofx_account_id', 'ofx_fitid'),
Index(
'fk_txn_reconciles_txn_id_transactions',
txn_id
),
Index(
'fk_txn_reconciles_ofx_account_id_ofx_trans',
ofx_account_id,
ofx_fitid
),
{'mysql_engine': 'InnoDB'}
)

def __repr__(self):
return "<TxnReconcile(id=%d)>" % (
self.id
Expand Down

0 comments on commit 26e307e

Please sign in to comment.