-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #747 from nkaretnikov/status-canceled-547
Add status `CANCELED`
- Loading branch information
Showing
8 changed files
with
89 additions
and
14 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
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,44 @@ | ||
"""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(): | ||
# There are foreign key constraints linking build ids to other tables. So | ||
# just mark the builds as failed, which was the status previously used for | ||
# canceled builds | ||
op.execute("UPDATE build SET status = 'FAILED' WHERE status = 'CANCELED'") |
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
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