chore: snapshot workflow migration progress
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
"""Add workflow rollout mode to output types.
|
||||
|
||||
Revision ID: 067
|
||||
Revises: 066
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = "067"
|
||||
down_revision = "066"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
"output_types",
|
||||
sa.Column(
|
||||
"workflow_rollout_mode",
|
||||
sa.String(length=20),
|
||||
nullable=False,
|
||||
server_default="legacy_only",
|
||||
),
|
||||
)
|
||||
op.execute(
|
||||
"""
|
||||
UPDATE output_types AS ot
|
||||
SET workflow_rollout_mode = CASE
|
||||
WHEN coalesce(wd.config->'ui'->>'execution_mode', 'legacy') = 'graph' THEN 'graph'
|
||||
WHEN coalesce(wd.config->'ui'->>'execution_mode', 'legacy') = 'shadow' THEN 'shadow'
|
||||
ELSE 'legacy_only'
|
||||
END
|
||||
FROM workflow_definitions AS wd
|
||||
WHERE ot.workflow_definition_id = wd.id
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("output_types", "workflow_rollout_mode")
|
||||
@@ -0,0 +1,55 @@
|
||||
"""Clean up persisted legacy Schaeffler material metadata.
|
||||
|
||||
Revision ID: 068
|
||||
Revises: 067
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
|
||||
revision = "068"
|
||||
down_revision = "067"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
_OLD_PREFIX = "SCHAEFFLER_"
|
||||
_NEW_PREFIX = "HARTOMAT_"
|
||||
|
||||
|
||||
def _replace_jsonb_prefix(table_name: str, column_name: str, old_prefix: str, new_prefix: str) -> None:
|
||||
op.execute(
|
||||
f"""
|
||||
UPDATE {table_name}
|
||||
SET {column_name} = replace({column_name}::text, '{old_prefix}', '{new_prefix}')::jsonb
|
||||
WHERE {column_name} IS NOT NULL
|
||||
AND {column_name}::text LIKE '%{old_prefix}%'
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def _replace_text_prefix(table_name: str, column_name: str, old_prefix: str, new_prefix: str) -> None:
|
||||
op.execute(
|
||||
f"""
|
||||
UPDATE {table_name}
|
||||
SET {column_name} = replace({column_name}, '{old_prefix}', '{new_prefix}')
|
||||
WHERE {column_name} IS NOT NULL
|
||||
AND {column_name} LIKE '%{old_prefix}%'
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
_replace_jsonb_prefix("cad_files", "resolved_material_assignments", _OLD_PREFIX, _NEW_PREFIX)
|
||||
_replace_jsonb_prefix("cad_files", "manual_material_overrides", _OLD_PREFIX, _NEW_PREFIX)
|
||||
_replace_jsonb_prefix("cad_files", "source_material_assignments", _OLD_PREFIX, _NEW_PREFIX)
|
||||
|
||||
_replace_text_prefix("output_types", "material_override", _OLD_PREFIX, _NEW_PREFIX)
|
||||
_replace_text_prefix("order_lines", "material_override", _OLD_PREFIX, _NEW_PREFIX)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
_replace_jsonb_prefix("cad_files", "resolved_material_assignments", _NEW_PREFIX, _OLD_PREFIX)
|
||||
_replace_jsonb_prefix("cad_files", "manual_material_overrides", _NEW_PREFIX, _OLD_PREFIX)
|
||||
_replace_jsonb_prefix("cad_files", "source_material_assignments", _NEW_PREFIX, _OLD_PREFIX)
|
||||
|
||||
_replace_text_prefix("output_types", "material_override", _NEW_PREFIX, _OLD_PREFIX)
|
||||
_replace_text_prefix("order_lines", "material_override", _NEW_PREFIX, _OLD_PREFIX)
|
||||
@@ -0,0 +1,31 @@
|
||||
"""Add workflow input schema to render templates.
|
||||
|
||||
Revision ID: 069
|
||||
Revises: 068
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
revision = "069"
|
||||
down_revision = "068"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
"render_templates",
|
||||
sa.Column(
|
||||
"workflow_input_schema",
|
||||
postgresql.JSONB(astext_type=sa.Text()),
|
||||
nullable=False,
|
||||
server_default=sa.text("'[]'::jsonb"),
|
||||
),
|
||||
)
|
||||
op.alter_column("render_templates", "workflow_input_schema", server_default=None)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("render_templates", "workflow_input_schema")
|
||||
Reference in New Issue
Block a user