-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return artefact status from api (#65)
* Return artefact status from api * Replace null artefact status with 'UNDECIDED' * Bug fixes
- Loading branch information
Showing
6 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...end/migrations/versions/2023_12_04_0820-8317277d4333_make_artefact_status_not_nullable.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,43 @@ | ||
"""Make artefact status not nullable | ||
Revision ID: 8317277d4333 | ||
Revises: 8d8643821588 | ||
Create Date: 2023-12-04 08:20:23.131927+00:00 | ||
""" | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "8317277d4333" | ||
down_revision = "8d8643821588" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.execute("ALTER TYPE artefact_status_enum RENAME TO artefact_status_enum_old") | ||
op.execute( | ||
"CREATE TYPE artefact_status_enum AS " | ||
"ENUM('APPROVED', 'MARKED_AS_FAILED', 'UNDECIDED')" | ||
) | ||
op.execute( | ||
"ALTER TABLE artefact ALTER COLUMN status TYPE " | ||
"artefact_status_enum USING status::text::artefact_status_enum" | ||
) | ||
op.execute("DROP TYPE artefact_status_enum_old") | ||
op.execute("UPDATE artefact SET status = 'UNDECIDED' WHERE status IS NULL") | ||
op.execute("ALTER TABLE artefact ALTER COLUMN status SET NOT NULL") | ||
|
||
|
||
def downgrade() -> None: | ||
op.execute("ALTER TYPE artefact_status_enum RENAME TO artefact_status_enum_old") | ||
op.execute( | ||
"CREATE TYPE artefact_status_enum AS ENUM('APPROVED', 'MARKED_AS_FAILED')" | ||
) | ||
op.execute("ALTER TABLE artefact ALTER COLUMN status DROP NOT NULL") | ||
op.execute("UPDATE artefact SET status = NULL WHERE status = 'UNDECIDED'") | ||
op.execute( | ||
"ALTER TABLE artefact ALTER COLUMN status TYPE " | ||
"artefact_status_enum USING status::text::artefact_status_enum" | ||
) | ||
op.execute("DROP TYPE artefact_status_enum_old") |
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