-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(db): Separate alembic versions into multiple files
- Loading branch information
1 parent
a685f0a
commit 1eb0288
Showing
6 changed files
with
272 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
"""Error tables for v0.4.0 | ||
Revision ID: 20428abf9581 | ||
Revises: f5e50e000a35 | ||
Create Date: 2024-12-13 22:07:55.828266+00:00 | ||
""" | ||
|
||
from collections.abc import Sequence | ||
|
||
import sqlalchemy as sa | ||
from sqlalchemy import MetaData | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "20428abf9581" | ||
down_revision: str | None = "f5e50e000a35" | ||
branch_labels: str | Sequence[str] | None = None | ||
depends_on: str | Sequence[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
# Create table for Pipetask Error Types | ||
op.create_table( | ||
"pipetask_error_type", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column( | ||
"error_source", | ||
sa.Enum( | ||
"cmservice", | ||
"local_script", | ||
"manifest", | ||
name="errorsourceenum", | ||
create_type=False, | ||
metadata=MetaData(), | ||
), | ||
nullable=False, | ||
), | ||
sa.Column( | ||
"error_flavor", | ||
sa.Enum( | ||
"infrastructure", | ||
"configuration", | ||
"pipelines", | ||
name="errorflavorenum", | ||
create_type=False, | ||
metadata=MetaData(), | ||
), | ||
nullable=False, | ||
), | ||
sa.Column( | ||
"error_action", | ||
sa.Enum( | ||
"fail", | ||
"requeue_and_pause", | ||
"rescue", | ||
"auto_retry", | ||
"review", | ||
"accept", | ||
name="erroractionenum", | ||
create_type=False, | ||
metadata=MetaData(), | ||
), | ||
nullable=False, | ||
), | ||
sa.Column("task_name", sa.String(), nullable=False), | ||
sa.Column("diagnostic_message", sa.String(), nullable=False), | ||
sa.PrimaryKeyConstraint("id"), | ||
sa.UniqueConstraint("task_name", "diagnostic_message"), | ||
) | ||
# Create table for Pipetask Errors | ||
op.create_table( | ||
"pipetask_error", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("error_type_id", sa.Integer(), nullable=True), | ||
sa.Column("task_id", sa.Integer(), nullable=False), | ||
sa.Column("quanta", sa.String(), nullable=False), | ||
sa.Column("diagnostic_message", sa.String(), nullable=False), | ||
sa.Column("data_id", sa.JSON(), nullable=True), | ||
sa.ForeignKeyConstraint(["error_type_id"], ["pipetask_error_type.id"], ondelete="CASCADE"), | ||
sa.ForeignKeyConstraint(["task_id"], ["task_set.id"], ondelete="CASCADE"), | ||
sa.PrimaryKeyConstraint("id"), | ||
sa.UniqueConstraint("quanta"), | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_table("pipetask_error") | ||
op.drop_table("pipetask_error_type") |
95 changes: 95 additions & 0 deletions
95
alembic/versions/92053b1ad093_separate_out_most_tables_and_indices.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
"""Separate out most tables and indices | ||
Revision ID: 92053b1ad093 | ||
Revises: d2a05fd9869c | ||
Create Date: 2024-12-16 20:45:33.619155+00:00 | ||
""" | ||
|
||
from collections.abc import Sequence | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "92053b1ad093" | ||
down_revision: str | None = "d2a05fd9869c" | ||
branch_labels: str | Sequence[str] | None = None | ||
depends_on: str | Sequence[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.create_index(op.f("ix_production_name"), "production", ["name"], unique=True) | ||
op.create_index(op.f("ix_spec_block_name"), "spec_block", ["name"], unique=False) | ||
op.create_index(op.f("ix_specification_name"), "specification", ["name"], unique=False) | ||
op.create_index(op.f("ix_campaign_name"), "campaign", ["name"], unique=False) | ||
op.create_index(op.f("ix_campaign_parent_id"), "campaign", ["parent_id"], unique=False) | ||
op.create_index(op.f("ix_campaign_spec_block_id"), "campaign", ["spec_block_id"], unique=False) | ||
op.create_index(op.f("ix_campaign_spec_id"), "campaign", ["spec_id"], unique=False) | ||
op.create_index(op.f("ix_step_name"), "step", ["name"], unique=False) | ||
op.create_index(op.f("ix_step_parent_id"), "step", ["parent_id"], unique=False) | ||
op.create_index(op.f("ix_step_spec_block_id"), "step", ["spec_block_id"], unique=False) | ||
op.create_index(op.f("ix_group_name"), "group", ["name"], unique=False) | ||
op.create_index(op.f("ix_group_parent_id"), "group", ["parent_id"], unique=False) | ||
op.create_index(op.f("ix_group_spec_block_id"), "group", ["spec_block_id"], unique=False) | ||
op.create_index(op.f("ix_step_dependency_depend_id"), "step_dependency", ["depend_id"], unique=False) | ||
op.create_index(op.f("ix_step_dependency_prereq_id"), "step_dependency", ["prereq_id"], unique=False) | ||
op.create_index(op.f("ix_job_name"), "job", ["name"], unique=False) | ||
op.create_index(op.f("ix_job_parent_id"), "job", ["parent_id"], unique=False) | ||
op.create_index(op.f("ix_job_spec_block_id"), "job", ["spec_block_id"], unique=False) | ||
op.create_index(op.f("ix_script_c_id"), "script", ["c_id"], unique=False) | ||
op.create_index(op.f("ix_script_g_id"), "script", ["g_id"], unique=False) | ||
op.create_index(op.f("ix_script_j_id"), "script", ["j_id"], unique=False) | ||
op.create_index(op.f("ix_script_name"), "script", ["name"], unique=False) | ||
op.create_index(op.f("ix_script_s_id"), "script", ["s_id"], unique=False) | ||
op.create_index(op.f("ix_script_spec_block_id"), "script", ["spec_block_id"], unique=False) | ||
op.create_index(op.f("ix_task_set_job_id"), "task_set", ["job_id"], unique=False) | ||
op.create_index(op.f("ix_wms_task_report_job_id"), "wms_task_report", ["job_id"], unique=False) | ||
op.create_index(op.f("ix_product_set_job_id"), "product_set", ["job_id"], unique=False) | ||
op.create_index(op.f("ix_product_set_task_id"), "product_set", ["task_id"], unique=False) | ||
op.create_index(op.f("ix_queue_c_id"), "queue", ["c_id"], unique=False) | ||
op.create_index(op.f("ix_queue_g_id"), "queue", ["g_id"], unique=False) | ||
op.create_index(op.f("ix_queue_j_id"), "queue", ["j_id"], unique=False) | ||
op.create_index(op.f("ix_queue_s_id"), "queue", ["s_id"], unique=False) | ||
op.create_index(op.f("ix_queue_script_id"), "queue", ["script_id"], unique=False) | ||
op.create_index(op.f("ix_script_dependency_depend_id"), "script_dependency", ["depend_id"], unique=False) | ||
op.create_index(op.f("ix_script_dependency_prereq_id"), "script_dependency", ["prereq_id"], unique=False) | ||
op.create_index(op.f("ix_script_error_script_id"), "script_error", ["script_id"], unique=False) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_index(op.f("ix_script_error_script_id"), table_name="script_error") | ||
op.drop_index(op.f("ix_script_dependency_prereq_id"), table_name="script_dependency") | ||
op.drop_index(op.f("ix_script_dependency_depend_id"), table_name="script_dependency") | ||
op.drop_index(op.f("ix_queue_script_id"), table_name="queue") | ||
op.drop_index(op.f("ix_queue_s_id"), table_name="queue") | ||
op.drop_index(op.f("ix_queue_j_id"), table_name="queue") | ||
op.drop_index(op.f("ix_queue_g_id"), table_name="queue") | ||
op.drop_index(op.f("ix_queue_c_id"), table_name="queue") | ||
op.drop_index(op.f("ix_product_set_task_id"), table_name="product_set") | ||
op.drop_index(op.f("ix_product_set_job_id"), table_name="product_set") | ||
op.drop_index(op.f("ix_wms_task_report_job_id"), table_name="wms_task_report") | ||
op.drop_index(op.f("ix_task_set_job_id"), table_name="task_set") | ||
op.drop_index(op.f("ix_script_spec_block_id"), table_name="script") | ||
op.drop_index(op.f("ix_script_s_id"), table_name="script") | ||
op.drop_index(op.f("ix_script_name"), table_name="script") | ||
op.drop_index(op.f("ix_script_j_id"), table_name="script") | ||
op.drop_index(op.f("ix_script_g_id"), table_name="script") | ||
op.drop_index(op.f("ix_script_c_id"), table_name="script") | ||
op.drop_index(op.f("ix_job_spec_block_id"), table_name="job") | ||
op.drop_index(op.f("ix_job_parent_id"), table_name="job") | ||
op.drop_index(op.f("ix_job_name"), table_name="job") | ||
op.drop_index(op.f("ix_step_dependency_prereq_id"), table_name="step_dependency") | ||
op.drop_index(op.f("ix_step_dependency_depend_id"), table_name="step_dependency") | ||
op.drop_index(op.f("ix_group_spec_block_id"), table_name="group") | ||
op.drop_index(op.f("ix_group_parent_id"), table_name="group") | ||
op.drop_index(op.f("ix_group_name"), table_name="group") | ||
op.drop_index(op.f("ix_step_spec_block_id"), table_name="step") | ||
op.drop_index(op.f("ix_step_parent_id"), table_name="step") | ||
op.drop_index(op.f("ix_step_name"), table_name="step") | ||
op.drop_index(op.f("ix_campaign_spec_id"), table_name="campaign") | ||
op.drop_index(op.f("ix_campaign_spec_block_id"), table_name="campaign") | ||
op.drop_index(op.f("ix_campaign_parent_id"), table_name="campaign") | ||
op.drop_index(op.f("ix_campaign_name"), table_name="campaign") | ||
op.drop_index(op.f("ix_specification_name"), table_name="specification") | ||
op.drop_index(op.f("ix_spec_block_name"), table_name="spec_block") | ||
op.drop_index(op.f("ix_production_name"), table_name="production") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Error indices for v0.4.0 | ||
Revision ID: cacc1bb4152e | ||
Revises: 92053b1ad093 | ||
Create Date: 2024-12-16 21:10:24.132473+00:00 | ||
""" | ||
|
||
from collections.abc import Sequence | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "cacc1bb4152e" | ||
down_revision: str | None = "92053b1ad093" | ||
branch_labels: str | Sequence[str] | None = None | ||
depends_on: str | Sequence[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.create_index( | ||
op.f("ix_pipetask_error_error_type_id"), "pipetask_error", ["error_type_id"], unique=False | ||
) | ||
op.create_index(op.f("ix_pipetask_error_task_id"), "pipetask_error", ["task_id"], unique=False) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_index(op.f("ix_pipetask_error_task_id"), table_name="pipetask_error") | ||
op.drop_index(op.f("ix_pipetask_error_error_type_id"), table_name="pipetask_error") |
33 changes: 33 additions & 0 deletions
33
alembic/versions/d2a05fd9869c_script_template_for_v0_4_0.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Script template for v0.4.0 | ||
Revision ID: d2a05fd9869c | ||
Revises: 20428abf9581 | ||
Create Date: 2024-12-16 20:24:15.129144+00:00 | ||
""" | ||
|
||
from collections.abc import Sequence | ||
|
||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "d2a05fd9869c" | ||
down_revision: str | None = "20428abf9581" | ||
branch_labels: str | Sequence[str] | None = None | ||
depends_on: str | Sequence[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.create_table( | ||
"script_template", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("name", sa.String(), nullable=False), | ||
sa.Column("data", sa.JSON(), nullable=True), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_table("script_template") |
Oops, something went wrong.