Update ofxrecord amount to valid monetary numeric type
We don't want no floats around here, this is money. This stuff matters. I also took the time to align up my comments so they are purtier
This commit is contained in:
parent
d479ca3850
commit
459a1b2960
|
@ -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
|
|
@ -1,6 +1,6 @@
|
||||||
import chryso.constants
|
import chryso.constants
|
||||||
from sqlalchemy import (Column, Date, DateTime, Float, ForeignKey, Integer,
|
from sqlalchemy import (Column, Date, DateTime, ForeignKey, Integer, MetaData,
|
||||||
MetaData, String, Table, UniqueConstraint, func, text)
|
Numeric, String, Table, UniqueConstraint, func, text)
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
from sqlalchemy.dialects.postgresql import UUID
|
||||||
|
|
||||||
metadata = MetaData(naming_convention=chryso.constants.CONVENTION)
|
metadata = MetaData(naming_convention=chryso.constants.CONVENTION)
|
||||||
|
@ -66,7 +66,7 @@ OFXUpdate = table('ofxupdate',
|
||||||
)
|
)
|
||||||
|
|
||||||
OFXRecord = table('ofxrecord',
|
OFXRecord = table('ofxrecord',
|
||||||
Column('amount', Float(), nullable=False), # The amount of the record, like -177.91
|
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('available', Date(), nullable=True), # The date the record was available
|
||||||
Column('fid', String(255), nullable=False), # The Financial institution's ID
|
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('name', String(1024), nullable=False), # The name of the record, like 'UT SLC SAMSCLUB #4719'
|
||||||
|
|
Loading…
Reference in New Issue