Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions migrations/versions/0aa283fddc29_replace_pro_supported_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""Replace pro_supported with esm_pro_supported and break_bug_pro_supported.
Revision ID: 0aa283fddc29
Revises: 20260322_01
Create Date: 2026-04-13 17:23:20.174684

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = '0aa283fddc29'
down_revision: Union[str, None] = '20260322_01'
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.add_column(
'versions',
sa.Column('esm_pro_supported', sa.JSON(), nullable=False),
)
op.add_column(
'versions',
sa.Column('break_bug_pro_supported', sa.JSON(), nullable=False),
)
op.add_column(
'versions',
sa.Column(
'is_hidden',
sa.Boolean(),
nullable=False,
server_default=sa.false(),
),
)
op.drop_column('versions', 'pro_supported')
op.drop_constraint(
"ck_deployments_artifact_type", "deployments", type_="check"
)
op.create_check_constraint(
"ck_deployments_artifact_type",
"deployments",
"artifact_type IN ('snap', 'deb', 'charm', 'image', 'rock')",
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
'versions',
sa.Column(
'pro_supported',
postgresql.JSON(astext_type=sa.Text()),
autoincrement=False,
nullable=False,
),
)
op.drop_column('versions', 'is_hidden')
op.drop_column('versions', 'break_bug_pro_supported')
op.drop_column('versions', 'esm_pro_supported')
op.drop_constraint(
"ck_deployments_artifact_type", "deployments", type_="check"
)
op.create_check_constraint(
"ck_deployments_artifact_type",
"deployments",
"artifact_type IN ('snap', 'deb', 'charm', 'image', 'rock', 'other')",
)
# ### end Alembic commands ###
4 changes: 3 additions & 1 deletion tests/fixtures/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ def make_version(product, deployment, **overrides):
"architecture": ["amd64"],
"release_date": {"date": "2020-01-01"},
"supported": future_date,
"pro_supported": future_date,
"esm_pro_supported": future_date,
"break_bug_pro_supported": future_date,
"legacy_supported": future_date,
"upgrade_path": None,
"compatible_ubuntu_lts": None,
"is_hidden": False,
}
return Version(**{**defaults, **overrides})

Expand Down
3 changes: 2 additions & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from tests.fixtures.models import make_deployment, make_product, make_version


def _add_product_with_version(db, product_slug, lifecycle_overrides):
def _add_product_with_version(db, product_slug, lifecycle_overrides, is_hidden=False):
product = make_product(
slug=product_slug,
name=f"Product {product_slug}",
Expand All @@ -15,6 +15,7 @@ def _add_product_with_version(db, product_slug, lifecycle_overrides):
product,
deployment,
release=f"{product_slug}-1.0.0",
is_hidden=is_hidden,
**lifecycle_overrides,
)
db.session.add(product)
Expand Down
Loading
Loading