We don't know yet how useful the job failue tables will be, and maintaining multiple failure tables--one for every entity involved in CSP provisioning--is burdensome. This collapses them all into a single table that track the entity type (environment, portfolio, etc.) and the entity ID. That way we can construct queries when needed to find task results.
61 lines
2.8 KiB
Python
61 lines
2.8 KiB
Python
"""combine job failures
|
|
|
|
Revision ID: 508957112ed6
|
|
Revises: 07e0598199f6
|
|
Create Date: 2020-01-25 15:03:06.377442
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '508957112ed6' # pragma: allowlist secret
|
|
down_revision = '07e0598199f6' # pragma: allowlist secret
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('job_failures',
|
|
sa.Column('time_created', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.Column('time_updated', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('task_id', sa.String(), nullable=False),
|
|
sa.Column('entity', sa.String(), nullable=False),
|
|
sa.Column('entity_id', sa.String(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.drop_table('environment_job_failures')
|
|
op.drop_table('environment_role_job_failures')
|
|
op.drop_table('portfolio_job_failures')
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('portfolio_job_failures',
|
|
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
|
sa.Column('task_id', sa.VARCHAR(), autoincrement=False, nullable=False),
|
|
sa.Column('portfolio_id', postgresql.UUID(), autoincrement=False, nullable=False),
|
|
sa.ForeignKeyConstraint(['portfolio_id'], ['portfolios.id'], name='portfolio_job_failures_portfolio_id_fkey'),
|
|
sa.PrimaryKeyConstraint('id', name='portfolio_job_failures_pkey')
|
|
)
|
|
op.create_table('environment_role_job_failures',
|
|
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
|
sa.Column('task_id', sa.VARCHAR(), autoincrement=False, nullable=False),
|
|
sa.Column('environment_role_id', postgresql.UUID(), autoincrement=False, nullable=False),
|
|
sa.ForeignKeyConstraint(['environment_role_id'], ['environment_roles.id'], name='environment_role_job_failures_environment_role_id_fkey'),
|
|
sa.PrimaryKeyConstraint('id', name='environment_role_job_failures_pkey')
|
|
)
|
|
op.create_table('environment_job_failures',
|
|
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
|
|
sa.Column('task_id', sa.VARCHAR(), autoincrement=False, nullable=False),
|
|
sa.Column('environment_id', postgresql.UUID(), autoincrement=False, nullable=False),
|
|
sa.ForeignKeyConstraint(['environment_id'], ['environments.id'], name='environment_job_failures_environment_id_fkey'),
|
|
sa.PrimaryKeyConstraint('id', name='environment_job_failures_pkey')
|
|
)
|
|
op.drop_table('job_failures')
|
|
# ### end Alembic commands ###
|