forked from conda-incubator/conda-store
-
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.
Showing
5 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
conda-store-server/conda_store_server/alembic/versions/03c839888c82_add_canceled_status.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,51 @@ | ||
"""add canceled status | ||
Revision ID: 03c839888c82 | ||
Revises: 57cd11b949d5 | ||
Create Date: 2024-01-29 03:56:36.889909 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "03c839888c82" | ||
down_revision = "57cd11b949d5" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
# Migrating from/to VARCHAR having the same length might look strange, but it | ||
# serves a purpose. This will be a no-op in SQLite because it represents Python | ||
# enums as VARCHAR, but it will convert the enum in PostgreSQL to VARCHAR. The | ||
# old type is set to VARCHAR here because you can cast an enum to VARCHAR, which | ||
# is needed for the migration to work. In the end, both DBs will use VARCHAR to | ||
# represent the Python enum, which makes it easier to support both DBs at the | ||
# same time. | ||
def upgrade(): | ||
with op.batch_alter_table( | ||
"build", | ||
schema=None, | ||
) as batch_op: | ||
batch_op.alter_column( | ||
"status", | ||
existing_type=sa.VARCHAR(length=9), | ||
type_=sa.VARCHAR(length=9), | ||
existing_nullable=False, | ||
) | ||
if not str(op.get_bind().engine.url).startswith("sqlite"): | ||
op.execute("DROP TYPE IF EXISTS buildstatus") | ||
|
||
|
||
def downgrade(): | ||
op.execute("DELETE FROM build WHERE status = 'CANCELED'") | ||
with op.batch_alter_table( | ||
"build", | ||
schema=None, | ||
) as batch_op: | ||
batch_op.alter_column( | ||
"status", | ||
existing_type=sa.VARCHAR(length=9), | ||
type_=sa.VARCHAR(length=9), | ||
existing_nullable=False, | ||
) |
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
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
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
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