Skip to content

Commit

Permalink
Add new components_json field to the jira_fields table.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-aranda committed Dec 16, 2024
1 parent d3db8b7 commit b85e26a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""add columns_json to jira_fields table
Revision ID: 1b085cf9c085
Revises: 54f755dbdb6f
Create Date: 2024-12-16 18:32:07.304537
"""
import logging

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "1b085cf9c085"
down_revision = "54f755dbdb6f"
branch_labels = None
depends_on = None

JIRA_FIELDS_TABLE_NAME = "jira_fields"


def upgrade(log: logging.Logger, table_names: set[str]) -> None:
if JIRA_FIELDS_TABLE_NAME not in table_names:
log.info(f"No {JIRA_FIELDS_TABLE_NAME} table; nothing to do")
return
log.info("Add 'columns_json'")

op.add_column(
JIRA_FIELDS_TABLE_NAME,
sa.Column("columns_json", sa.JSON(), nullable=True),
)


def downgrade(log: logging.Logger, table_names: set[str]) -> None:
if JIRA_FIELDS_TABLE_NAME not in table_names:
log.info(f"No {JIRA_FIELDS_TABLE_NAME} table; nothing to do")
return

log.info("Drop 'columns_json'")
op.drop_column(JIRA_FIELDS_TABLE_NAME, "columns_json")
6 changes: 5 additions & 1 deletion src/narrativelog/create_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import sqlalchemy as sa
import sqlalchemy.types as saty
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.dialects.postgresql import JSONB, UUID

# Length of the site_id field.
SITE_ID_LEN = 16
Expand Down Expand Up @@ -110,6 +110,10 @@ def create_jira_fields_table(metadata: sa.MetaData) -> sa.Table:
sa.Column(
"id", UUID(as_uuid=True), primary_key=True, default=uuid.uuid4
),
# Added 2024-12-16
sa.Column("components_json", JSONB, nullable=True),
# Following columns: components, primary_software_components,
# primary_hardware_components will be deprecated in version 1.0.0
sa.Column("components", saty.ARRAY(sa.Text), nullable=True),
sa.Column(
"primary_software_components", saty.ARRAY(sa.Text), nullable=True
Expand Down

0 comments on commit b85e26a

Please sign in to comment.