From d17c592908ead218867ca9e92b191f0ccf0f3fa2 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Tue, 21 Jun 2016 07:13:14 -0600 Subject: [PATCH] Make every OFXAccount have an owner That way we can split out accounts by the user that created them. Y'know, like permissions for multi-tenancy --- .../6b5382ac7616_add_owner_ofxaccount.py | 26 +++++++++++++++++++ vanth/tables.py | 1 + 2 files changed, 27 insertions(+) create mode 100644 alembic/versions/6b5382ac7616_add_owner_ofxaccount.py diff --git a/alembic/versions/6b5382ac7616_add_owner_ofxaccount.py b/alembic/versions/6b5382ac7616_add_owner_ofxaccount.py new file mode 100644 index 0000000..deeaed3 --- /dev/null +++ b/alembic/versions/6b5382ac7616_add_owner_ofxaccount.py @@ -0,0 +1,26 @@ +"""add owner ofxaccount + +Revision ID: 6b5382ac7616 +Revises: 4990a9f1ada3 +Create Date: 2016-06-21 07:12:22.486560 + +""" + +# revision identifiers, used by Alembic. +revision = '6b5382ac7616' +down_revision = '4990a9f1ada3' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +def upgrade(): + op.add_column('ofxaccount', sa.Column('owner', postgresql.UUID(), nullable=False)) + op.create_foreign_key('fk_user', 'ofxaccount', 'users', ['owner'], ['uuid']) + + +def downgrade(): + op.drop_constraint('fk_user', 'ofxaccount', type_='foreignkey') + op.drop_column('ofxaccount', 'owner') diff --git a/vanth/tables.py b/vanth/tables.py index 6213bf2..3c78356 100644 --- a/vanth/tables.py +++ b/vanth/tables.py @@ -50,6 +50,7 @@ OFXAccount = Table('ofxaccount', metadata, Column('password', String(255), nullable=False), # The encrypted password for the account Column('type', String(255), nullable=False), # The account type, like 'checking' Column('source', None, ForeignKey(OFXSource.c.uuid, name='fk_ofxsource'), nullable=False), + Column('owner', None, ForeignKey(User.c.uuid, name='fk_user'), nullable=False), Column('created', DateTime(), nullable=False, server_default=func.now()), Column('updated', DateTime(), nullable=False, server_default=func.now(), onupdate=func.now()), )