Skip to content

Commit

Permalink
Merge pull request #21 from lsst-sqre/tickets/DM-40727
Browse files Browse the repository at this point in the history
DM-40727: add missing migration
  • Loading branch information
sebastian-aranda authored Sep 12, 2023
2 parents 2ad537e + ae67f98 commit d373e35
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Change Log
==========

0.5.1
-----

* Add missing migration to set 'systems', 'subsystems', and 'cscs' as nullable fields.

0.5.0
-----

Expand Down
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)

0 comments on commit d373e35

Please sign in to comment.