-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Wrong container registry migration script (#2949)
- Loading branch information
1 parent
e8664f6
commit c9aa707
Showing
3 changed files
with
82 additions
and
6 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 @@ | ||
Fix wrong container registry migration script. |
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
34 changes: 34 additions & 0 deletions
34
...d/manager/models/alembic/versions/e9e574a6e22d_add_extra_column_to_container_registrys.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,34 @@ | ||
"""Add extra column to container_registries | ||
Revision ID: e9e574a6e22d | ||
Revises: 7c8501cec07b | ||
Create Date: 2024-10-23 20:56:36.513421 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.engine.reflection import Inspector | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "e9e574a6e22d" | ||
down_revision = "7c8501cec07b" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
conn = op.get_bind() | ||
inspector = Inspector.from_engine(conn) | ||
columns = [col["name"] for col in inspector.get_columns("container_registries")] | ||
|
||
# Prevent error in case the extra column was created using a previously modified migration script. | ||
if "extra" not in columns: | ||
op.add_column( | ||
"container_registries", | ||
sa.Column("extra", sa.JSON, default=None, nullable=True), | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_column("container_registries", "extra") |