From b8345d097c93b84404c50d4fd9081d291badc587 Mon Sep 17 00:00:00 2001 From: Sebastian Aranda Sanchez Date: Mon, 11 Sep 2023 18:08:02 -0300 Subject: [PATCH 1/2] Add migration to set nullable fields for 'systems', 'subsystems' and 'cscs' columns of 'messages' table --- ...pdate_message_table_systems_subsystems_.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 alembic/versions/d9606992ad8d_update_message_table_systems_subsystems_.py diff --git a/alembic/versions/d9606992ad8d_update_message_table_systems_subsystems_.py b/alembic/versions/d9606992ad8d_update_message_table_systems_subsystems_.py new file mode 100644 index 0000000..0148506 --- /dev/null +++ b/alembic/versions/d9606992ad8d_update_message_table_systems_subsystems_.py @@ -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) From ae67f98405505c4a6dfb653b4dbc727e0b6bfaea Mon Sep 17 00:00:00 2001 From: Sebastian Aranda Sanchez Date: Tue, 12 Sep 2023 09:20:13 -0300 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9bc2af2..6c4868c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,11 @@ Change Log ========== +0.5.1 +----- + +* Add missing migration to set 'systems', 'subsystems', and 'cscs' as nullable fields. + 0.5.0 -----