-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add workflow_permanent_id unique constraint and index to workflows ta…
…ble (#309)
- Loading branch information
1 parent
b959822
commit a4ed6de
Showing
2 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
alembic/versions/2024_05_14_0245-baec12642d77_add_workflow_permanent_id_constraint_.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,40 @@ | ||
"""Add workflow_permanent_id constraint and index to workflows table | ||
Revision ID: baec12642d77 | ||
Revises: bf561125112f | ||
Create Date: 2024-05-14 02:45:11.284376+00:00 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
import sqlalchemy as sa | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "baec12642d77" | ||
down_revision: Union[str, None] = "bf561125112f" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.alter_column("workflows", "workflow_permanent_id", existing_type=sa.VARCHAR(), nullable=False) | ||
op.alter_column("workflows", "version", existing_type=sa.INTEGER(), nullable=False) | ||
op.create_index(op.f("ix_workflows_workflow_permanent_id"), "workflows", ["workflow_permanent_id"], unique=False) | ||
op.create_index("permanent_id_version_idx", "workflows", ["workflow_permanent_id", "version"], unique=False) | ||
op.create_unique_constraint( | ||
"uc_org_permanent_id_version", "workflows", ["organization_id", "workflow_permanent_id", "version"] | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint("uc_org_permanent_id_version", "workflows", type_="unique") | ||
op.drop_index("permanent_id_version_idx", table_name="workflows") | ||
op.drop_index(op.f("ix_workflows_workflow_permanent_id"), table_name="workflows") | ||
op.alter_column("workflows", "version", existing_type=sa.INTEGER(), nullable=True) | ||
op.alter_column("workflows", "workflow_permanent_id", existing_type=sa.VARCHAR(), nullable=True) | ||
# ### end Alembic commands ### |
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