Grow all ID fields for Harvest cache tables

turns out Integer is not big enough, need BigInteger
This commit is contained in:
Lance Edgar 2023-08-08 11:05:15 -05:00
parent d508ca225b
commit 2fa7ef5e71
2 changed files with 101 additions and 12 deletions

View file

@ -0,0 +1,89 @@
# -*- coding: utf-8; -*-
"""grow id fields
Revision ID: f2a1650e7fbc
Revises: 6bc1cb21d920
Create Date: 2023-08-08 10:53:56.013211
"""
# revision identifiers, used by Alembic.
revision = 'f2a1650e7fbc'
down_revision = '6bc1cb21d920'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
import rattail.db.types
from sqlalchemy.dialects import postgresql
def upgrade():
# harvest_user
op.alter_column('harvest_user', 'id', type_=sa.BigInteger())
op.alter_column('harvest_user_version', 'id', type_=sa.BigInteger())
# harvest_client
op.alter_column('harvest_client', 'id', type_=sa.BigInteger())
op.alter_column('harvest_client_version', 'id', type_=sa.BigInteger())
# harvest_project
op.alter_column('harvest_project', 'id', type_=sa.BigInteger())
op.alter_column('harvest_project', 'client_id', type_=sa.BigInteger())
op.alter_column('harvest_project_version', 'id', type_=sa.BigInteger())
op.alter_column('harvest_project_version', 'client_id', type_=sa.BigInteger())
# harvest_task
op.alter_column('harvest_task', 'id', type_=sa.BigInteger())
op.alter_column('harvest_task_version', 'id', type_=sa.BigInteger())
# harvest_time_entry
op.alter_column('harvest_time_entry', 'id', type_=sa.BigInteger())
op.alter_column('harvest_time_entry', 'user_id', type_=sa.BigInteger())
op.alter_column('harvest_time_entry', 'client_id', type_=sa.BigInteger())
op.alter_column('harvest_time_entry', 'project_id', type_=sa.BigInteger())
op.alter_column('harvest_time_entry', 'task_id', type_=sa.BigInteger())
op.alter_column('harvest_time_entry', 'invoice_id', type_=sa.BigInteger())
op.alter_column('harvest_time_entry_version', 'id', type_=sa.BigInteger())
op.alter_column('harvest_time_entry_version', 'user_id', type_=sa.BigInteger())
op.alter_column('harvest_time_entry_version', 'client_id', type_=sa.BigInteger())
op.alter_column('harvest_time_entry_version', 'project_id', type_=sa.BigInteger())
op.alter_column('harvest_time_entry_version', 'task_id', type_=sa.BigInteger())
op.alter_column('harvest_time_entry_version', 'invoice_id', type_=sa.BigInteger())
def downgrade():
# harvest_time_entry
op.alter_column('harvest_time_entry_version', 'id', type_=sa.Integer())
op.alter_column('harvest_time_entry_version', 'user_id', type_=sa.Integer())
op.alter_column('harvest_time_entry_version', 'client_id', type_=sa.Integer())
op.alter_column('harvest_time_entry_version', 'project_id', type_=sa.Integer())
op.alter_column('harvest_time_entry_version', 'task_id', type_=sa.Integer())
op.alter_column('harvest_time_entry_version', 'invoice_id', type_=sa.Integer())
op.alter_column('harvest_time_entry', 'id', type_=sa.Integer())
op.alter_column('harvest_time_entry', 'user_id', type_=sa.Integer())
op.alter_column('harvest_time_entry', 'client_id', type_=sa.Integer())
op.alter_column('harvest_time_entry', 'project_id', type_=sa.Integer())
op.alter_column('harvest_time_entry', 'task_id', type_=sa.Integer())
op.alter_column('harvest_time_entry', 'invoice_id', type_=sa.Integer())
# harvest_task
op.alter_column('harvest_task_version', 'id', type_=sa.Integer())
op.alter_column('harvest_task', 'id', type_=sa.Integer())
# harvest_project
op.alter_column('harvest_project_version', 'id', type_=sa.Integer())
op.alter_column('harvest_project_version', 'client_id', type_=sa.Integer())
op.alter_column('harvest_project', 'id', type_=sa.Integer())
op.alter_column('harvest_project', 'client_id', type_=sa.Integer())
# harvest_client
op.alter_column('harvest_client_version', 'id', type_=sa.Integer())
op.alter_column('harvest_client', 'id', type_=sa.Integer())
# harvest_user
op.alter_column('harvest_user_version', 'id', type_=sa.Integer())
op.alter_column('harvest_user', 'id', type_=sa.Integer())

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2022 Lance Edgar # Copyright © 2010-2023 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -46,7 +46,7 @@ class HarvestUser(model.Base):
uuid = model.uuid_column() uuid = model.uuid_column()
id = sa.Column(sa.Integer(), nullable=False) id = sa.Column(sa.BigInteger(), nullable=False)
first_name = sa.Column(sa.String(length=255), nullable=True) first_name = sa.Column(sa.String(length=255), nullable=True)
@ -122,7 +122,7 @@ class HarvestClient(model.Base):
uuid = model.uuid_column() uuid = model.uuid_column()
id = sa.Column(sa.Integer(), nullable=False) id = sa.Column(sa.BigInteger(), nullable=False)
name = sa.Column(sa.String(length=255), nullable=True) name = sa.Column(sa.String(length=255), nullable=True)
@ -155,9 +155,9 @@ class HarvestProject(model.Base):
uuid = model.uuid_column() uuid = model.uuid_column()
id = sa.Column(sa.Integer(), nullable=False) id = sa.Column(sa.BigInteger(), nullable=False)
client_id = sa.Column(sa.Integer(), nullable=True) # TODO: should not allow null? client_id = sa.Column(sa.BigInteger(), nullable=True) # TODO: should not allow null?
client = orm.relationship(HarvestClient, backref=orm.backref('projects')) client = orm.relationship(HarvestClient, backref=orm.backref('projects'))
name = sa.Column(sa.String(length=255), nullable=True) name = sa.Column(sa.String(length=255), nullable=True)
@ -226,7 +226,7 @@ class HarvestTask(model.Base):
uuid = model.uuid_column() uuid = model.uuid_column()
id = sa.Column(sa.Integer(), nullable=False) id = sa.Column(sa.BigInteger(), nullable=False)
name = sa.Column(sa.String(length=255), nullable=True) name = sa.Column(sa.String(length=255), nullable=True)
@ -265,23 +265,23 @@ class HarvestTimeEntry(model.Base):
uuid = model.uuid_column() uuid = model.uuid_column()
id = sa.Column(sa.Integer(), nullable=False) id = sa.Column(sa.BigInteger(), nullable=False)
spent_date = sa.Column(sa.Date(), nullable=True) spent_date = sa.Column(sa.Date(), nullable=True)
user_id = sa.Column(sa.Integer(), nullable=True) user_id = sa.Column(sa.BigInteger(), nullable=True)
user = orm.relationship(HarvestUser, backref=orm.backref('time_entries')) user = orm.relationship(HarvestUser, backref=orm.backref('time_entries'))
client_id = sa.Column(sa.Integer(), nullable=True) client_id = sa.Column(sa.BigInteger(), nullable=True)
client = orm.relationship(HarvestClient, backref=orm.backref('time_entries')) client = orm.relationship(HarvestClient, backref=orm.backref('time_entries'))
project_id = sa.Column(sa.Integer(), nullable=True) project_id = sa.Column(sa.BigInteger(), nullable=True)
project = orm.relationship(HarvestProject, backref=orm.backref('time_entries')) project = orm.relationship(HarvestProject, backref=orm.backref('time_entries'))
task_id = sa.Column(sa.Integer(), nullable=True) task_id = sa.Column(sa.BigInteger(), nullable=True)
task = orm.relationship(HarvestTask, backref=orm.backref('time_entries')) task = orm.relationship(HarvestTask, backref=orm.backref('time_entries'))
invoice_id = sa.Column(sa.Integer(), nullable=True) invoice_id = sa.Column(sa.BigInteger(), nullable=True)
hours = sa.Column(sa.Numeric(precision=6, scale=2), nullable=True) hours = sa.Column(sa.Numeric(precision=6, scale=2), nullable=True)