Skip to content

Commit

Permalink
added migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tom0827 committed Oct 23, 2023
1 parent e599675 commit 9c8c9ee
Show file tree
Hide file tree
Showing 5 changed files with 11,161 additions and 5,357 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""rename work columns
Revision ID: 2257493941e7
Revises: 7deec389ae56
Create Date: 2023-10-23 16:12:30.470016
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '2257493941e7'
down_revision = '7deec389ae56'
branch_labels = None
depends_on = None


def upgrade():
with op.batch_alter_table('works', schema=None) as batch_op:
batch_op.alter_column('short_description', new_column_name='report_description')
batch_op.alter_column('long_description', new_column_name='epic_description')
batch_op.alter_column('is_watched', new_column_name='is_high_priority')
batch_op.drop_column('is_pecp_required')
with op.batch_alter_table('works_history', schema=None) as batch_op:
batch_op.add_column(sa.Column('report_description', sa.String(length=2000), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('epic_description', sa.Text(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('is_high_priority', sa.Boolean(), autoincrement=False, nullable=False))
batch_op.drop_column('is_watched')
batch_op.drop_column('short_description')
batch_op.drop_column('is_pecp_required')
batch_op.drop_column('long_description')


def downgrade():
with op.batch_alter_table('works', schema=None) as batch_op:
batch_op.alter_column('epic_description', new_column_name='long_description')
batch_op.alter_column('report_description', new_column_name='short_description')
batch_op.alter_column('is_high_priority', new_column_name='is_watched')
batch_op.add_column(sa.Column('is_pecp_required', sa.Boolean(), nullable=False, default=False))
with op.batch_alter_table('works_history', schema=None) as batch_op:
batch_op.add_column(sa.Column('long_description', sa.TEXT(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('is_pecp_required', sa.BOOLEAN(), autoincrement=False, nullable=False))
batch_op.add_column(sa.Column('short_description', sa.VARCHAR(length=2000), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('is_watched', sa.BOOLEAN(), autoincrement=False, nullable=False))
batch_op.drop_column('is_high_priority')
batch_op.drop_column('epic_description')
batch_op.drop_column('report_description')
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""make columns not nullable
Revision ID: eed10a65e3c3
Revises: 2257493941e7
Create Date: 2023-10-23 16:17:27.132349
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'eed10a65e3c3'
down_revision = '2257493941e7'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('works', schema=None) as batch_op:
batch_op.alter_column('eao_team_id',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.alter_column('responsible_epd_id',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.alter_column('work_lead_id',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.alter_column('decision_by_id',
existing_type=sa.INTEGER(),
nullable=False)

with op.batch_alter_table('works_history', schema=None) as batch_op:
batch_op.alter_column('eao_team_id',
existing_type=sa.INTEGER(),
nullable=False,
autoincrement=False)
batch_op.alter_column('responsible_epd_id',
existing_type=sa.INTEGER(),
nullable=False,
autoincrement=False)
batch_op.alter_column('work_lead_id',
existing_type=sa.INTEGER(),
nullable=False,
autoincrement=False)
batch_op.alter_column('decision_by_id',
existing_type=sa.INTEGER(),
nullable=False,
autoincrement=False)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('works_history', schema=None) as batch_op:
batch_op.alter_column('decision_by_id',
existing_type=sa.INTEGER(),
nullable=True,
autoincrement=False)
batch_op.alter_column('work_lead_id',
existing_type=sa.INTEGER(),
nullable=True,
autoincrement=False)
batch_op.alter_column('responsible_epd_id',
existing_type=sa.INTEGER(),
nullable=True,
autoincrement=False)
batch_op.alter_column('eao_team_id',
existing_type=sa.INTEGER(),
nullable=True,
autoincrement=False)

with op.batch_alter_table('works', schema=None) as batch_op:
batch_op.alter_column('decision_by_id',
existing_type=sa.INTEGER(),
nullable=True)
batch_op.alter_column('work_lead_id',
existing_type=sa.INTEGER(),
nullable=True)
batch_op.alter_column('responsible_epd_id',
existing_type=sa.INTEGER(),
nullable=True)
batch_op.alter_column('eao_team_id',
existing_type=sa.INTEGER(),
nullable=True)

# ### end Alembic commands ###
6 changes: 6 additions & 0 deletions epictrack-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions epictrack-api/src/api/models/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ class Work(BaseModelVersioned):
project_id = Column(ForeignKey('projects.id'), nullable=False)
ministry_id = Column(ForeignKey('ministries.id'), nullable=False)
ea_act_id = Column(ForeignKey('ea_acts.id'), nullable=False)
eao_team_id = Column(ForeignKey('eao_teams.id'), nullable=True)
eao_team_id = Column(ForeignKey('eao_teams.id'), nullable=False)
federal_involvement_id = Column(ForeignKey('federal_involvements.id'), nullable=False)
responsible_epd_id = Column(ForeignKey('staffs.id'), nullable=True)
work_lead_id = Column(ForeignKey('staffs.id'), nullable=True)
responsible_epd_id = Column(ForeignKey('staffs.id'), nullable=False)
work_lead_id = Column(ForeignKey('staffs.id'), nullable=False)
work_type_id = Column(ForeignKey('work_types.id'), nullable=False)
current_phase_id = Column(ForeignKey('phase_codes.id'), nullable=True, default=None)
substitution_act_id = Column(ForeignKey('substitution_acts.id'), nullable=True, default=None)
eac_decision_by_id = Column(ForeignKey('staffs.id'), nullable=True)
decision_by_id = Column(ForeignKey('staffs.id'), nullable=True)
decision_by_id = Column(ForeignKey('staffs.id'), nullable=False)
start_date_locked = Column(Boolean(), default=False)
decision_maker_position_id = Column(ForeignKey('positions.id'), nullable=True)

Expand Down
Loading

0 comments on commit 9c8c9ee

Please sign in to comment.