Get alembic up and running

I took a stab at a reasonable schema just to get started. For now I want
workflows that are working. I'll pound the thing into the correct shape
in time
This commit is contained in:
Eli Ribble 2016-05-02 08:44:54 -06:00
parent 3e4eab0802
commit 681a62bbf5
7 changed files with 304 additions and 0 deletions

54
vanth/tables.py Normal file
View file

@ -0,0 +1,54 @@
from sqlalchemy import Boolean, Column, Date, DateTime, Float, ForeignKey, Integer, MetaData, String, Table, func
from sqlalchemy.dialects.postgresql import UUID, ENUM
from sqlalchemy.dialects import postgres
import chryso.constants
metadata = MetaData(naming_convention=chryso.constants.CONVENTION)
CreditCard = Table('credit_card', metadata,
Column('uuid', UUID(as_uuid=True), primary_key=True),
Column('brand', String(20), nullable=False), # The brand of the card, like 'visa'
Column('card_id', String(100), nullable=False), # The ID of the card from Stripe
Column('country', String(1024), nullable=False), # The Country of the card, like 'US'
Column('cvc_check', String(100), nullable=False), # The CVC value from Stripe, like 'unchecked'
Column('expiration_month', Integer(), nullable=False), # The month the card expires
Column('expiration_year', Integer(), nullable=False), # The year the card expires
Column('last_four', Integer(), nullable=False), # The last four digits of the card
Column('token', String(), nullable=False), # The token we can use with Stripe to do stuff
Column('user_uri', String(2048), nullable=False), # The URI of the user that created the record
Column('created', DateTime(), nullable=False, server_default=func.now()),
Column('updated', DateTime(), nullable=False, server_default=func.now(), onupdate=func.now()),
Column('deleted', DateTime(), nullable=True),
)
OFXSource = Table('ofxsource', metadata,
Column('uuid', UUID(as_uuid=True), primary_key=True),
Column('name', String(255), nullable=False), # The name of the institution such as 'America First Credit Union'
Column('fid', String(255), nullable=False), # The FID of the institution, such as 54324
Column('bankid', String(255), nullable=False), # The bank ID of the institution such as 324377516
Column('created', DateTime(), nullable=False, server_default=func.now()),
Column('updated', DateTime(), nullable=False, server_default=func.now(), onupdate=func.now()),
)
OFXAccount = Table('ofxaccount', metadata,
Column('uuid', UUID(as_uuid=True), primary_key=True),
Column('user_id', String(255), nullable=False), # The user ID for the bank
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('created', DateTime(), nullable=False, server_default=func.now()),
Column('updated', DateTime(), nullable=False, server_default=func.now(), onupdate=func.now()),
)
OFXRecord = Table('ofxrecord', metadata,
Column('uuid', UUID(as_uuid=True), primary_key=True),
Column('fid', String(255), nullable=False), # The Financial institution's ID
Column('amount', Float(), nullable=False), # The amount of the record, like -177.91
Column('available', Date(), nullable=True), # The date the record was available
Column('name', String(1024), nullable=False), # The name of the record, like 'UT SLC SAMSCLUB #4719'
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('created', DateTime(), nullable=False, server_default=func.now()),
Column('updated', DateTime(), nullable=False, server_default=func.now(), onupdate=func.now()),
)