-
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.
Merge pull request #21 from lsst-sqre/tickets/DM-40727
DM-40727: add missing migration
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 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
40 changes: 40 additions & 0 deletions
40
alembic/versions/d9606992ad8d_update_message_table_systems_subsystems_.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,40 @@ | ||
"""update message table systems, subsystems and cscs fields | ||
Revision ID: d9606992ad8d | ||
Revises: b631d21eb6dc | ||
Create Date: 2023-09-11 17:44:07.705399 | ||
""" | ||
import logging | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "d9606992ad8d" | ||
down_revision = "b631d21eb6dc" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
MESSAGE_TABLE_NAME = "message" | ||
|
||
|
||
def upgrade(log: logging.Logger, table_names: set[str]): | ||
if MESSAGE_TABLE_NAME not in table_names: | ||
log.info(f"No {MESSAGE_TABLE_NAME} table; nothing to do") | ||
return | ||
log.info("Set columns 'systems', 'subsystems', and 'cscs' as nullable") | ||
|
||
op.alter_column(MESSAGE_TABLE_NAME, "systems", nullable=True) | ||
op.alter_column(MESSAGE_TABLE_NAME, "subsystems", nullable=True) | ||
op.alter_column(MESSAGE_TABLE_NAME, "cscs", nullable=True) | ||
|
||
|
||
def downgrade(log: logging.Logger, table_names: set[str]): | ||
if MESSAGE_TABLE_NAME not in table_names: | ||
log.info(f"No {MESSAGE_TABLE_NAME} table; nothing to do") | ||
return | ||
|
||
log.info("Set columns 'systems', 'subsystems', and 'cscs' as not nullable") | ||
op.alter_column(MESSAGE_TABLE_NAME, "systems", nullable=False) | ||
op.alter_column(MESSAGE_TABLE_NAME, "subsystems", nullable=False) | ||
op.alter_column(MESSAGE_TABLE_NAME, "cscs", nullable=False) |