diff --git a/alembic/versions/eac3a08698a7_fix_currency_type.py b/alembic/versions/eac3a08698a7_fix_currency_type.py new file mode 100644 index 0000000..47e33dd --- /dev/null +++ b/alembic/versions/eac3a08698a7_fix_currency_type.py @@ -0,0 +1,27 @@ +"""fix currency type + +Revision ID: eac3a08698a7 +Revises: 00f2b77f1d2c +Create Date: 2016-07-01 11:54:56.272364 + +""" + +# revision identifiers, used by Alembic. +revision = 'eac3a08698a7' +down_revision = '00f2b77f1d2c' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + if not op.get_context().as_sql: + connection = op.get_bind() + connection.execution_options(isolation_level='AUTOCOMMIT') + + op.execute('ALTER TABLE ofxrecord ALTER COLUMN amount TYPE NUMERIC(20, 2) USING amount::numeric;') + +def downgrade(): + pass diff --git a/vanth/tables.py b/vanth/tables.py index d42d4a9..abdbfe7 100644 --- a/vanth/tables.py +++ b/vanth/tables.py @@ -1,6 +1,6 @@ import chryso.constants -from sqlalchemy import (Column, Date, DateTime, Float, ForeignKey, Integer, - MetaData, String, Table, UniqueConstraint, func, text) +from sqlalchemy import (Column, Date, DateTime, ForeignKey, Integer, MetaData, + Numeric, String, Table, UniqueConstraint, func, text) from sqlalchemy.dialects.postgresql import UUID metadata = MetaData(naming_convention=chryso.constants.CONVENTION) @@ -66,12 +66,12 @@ OFXUpdate = table('ofxupdate', ) OFXRecord = table('ofxrecord', - 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('amount', Numeric(precision=20, scale=2, asdecimal=True), nullable=False), # The amount of the record, like -177.91 + Column('available', Date(), nullable=True), # The date the record was available Column('fid', String(255), nullable=False), # The Financial institution's ID Column('name', String(1024), nullable=False), # The name of the record, like 'UT SLC SAMSCLUB #4719' - Column('memo', String(2048), nullable=True), # The memo of the transaction, like 'POINT OF SALE PURCHASE #0005727' + Column('memo', String(2048), nullable=True), # The memo of the transaction, like 'POINT OF SALE PURCHASE #0005727' Column('ofxaccount', None, ForeignKey(OFXAccount.c.uuid, name='fk_ofxaccount'), nullable=False), - Column('posted', Date(), nullable=True), # The date the record posted - Column('type', String(255), nullable=True), # The type of the record, like 'POS' + Column('posted', Date(), nullable=True), # The date the record posted + Column('type', String(255), nullable=True), # The type of the record, like 'POS' )