Add a foreign key from OFXRecord to the OFXAccount used to get it
This makes it easier to tie together our records to the accounts we used to pull the record
This commit is contained in:
parent
e2821457f5
commit
1f978a3f28
|
@ -0,0 +1,30 @@
|
|||
"""ofxrecord fk ofxaccount
|
||||
|
||||
Revision ID: 2d295ac0fc07
|
||||
Revises: d68c4fbb811f
|
||||
Create Date: 2016-06-23 08:29:29.911075
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2d295ac0fc07'
|
||||
down_revision = 'd68c4fbb811f'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('ofxrecord', sa.Column('ofxaccount', postgresql.UUID(as_uuid=True), nullable=False))
|
||||
op.create_foreign_key('fk_ofxaccount', 'ofxrecord', 'ofxaccount', ['ofxaccount'], ['uuid'])
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint('fk_ofxaccount', 'ofxrecord', type_='foreignkey')
|
||||
op.drop_column('ofxrecord', 'ofxaccount')
|
||||
### end Alembic commands ###
|
|
@ -65,6 +65,7 @@ OFXRecord = Table('ofxrecord', metadata,
|
|||
Column('posted', Date(), nullable=True), # The date the record posted
|
||||
Column('memo', String(2048), nullable=True), # The memo of the transaction, like 'POINT OF SALE PURCHASE #0005727'
|
||||
Column('type', String(255), nullable=True), # The type of the record, like 'POS'
|
||||
Column('ofxaccount', None, ForeignKey(OFXAccount.c.uuid, name='fk_ofxaccount'), nullable=False),
|
||||
Column('created', DateTime(), nullable=False, server_default=func.now()),
|
||||
Column('updated', DateTime(), nullable=False, server_default=func.now(), onupdate=func.now()),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue