diff --git a/alembic/versions/2d295ac0fc07_ofxrecord_fk_ofxaccount.py b/alembic/versions/2d295ac0fc07_ofxrecord_fk_ofxaccount.py new file mode 100644 index 0000000..80eb9c7 --- /dev/null +++ b/alembic/versions/2d295ac0fc07_ofxrecord_fk_ofxaccount.py @@ -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 ### diff --git a/vanth/tables.py b/vanth/tables.py index 10c489a..1a4c3dc 100644 --- a/vanth/tables.py +++ b/vanth/tables.py @@ -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()), )