Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/soa_builder/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
_migrate_instances_add_member_of_timeline,
_migrate_matrix_cells_add_instance_id,
_migrate_activity_concept_add_href,
_migrate_activity_concept_add_dss,
_migrate_study_cell_add_order_index,
)
from .routers import activities as activities_router
Expand Down Expand Up @@ -155,6 +156,7 @@ def _configure_logging():
# Database migration steps
_migrate_study_cell_add_order_index()
_migrate_activity_concept_add_href()
_migrate_activity_concept_add_dss()
_migrate_matrix_cells_add_instance_id()
_migrate_instances_add_member_of_timeline()
_migrate_timing_add_member_of_timeline()
Expand Down Expand Up @@ -186,6 +188,7 @@ def _configure_logging():
app.include_router(elements_router.router)
app.include_router(visits_router.router)
app.include_router(activities_router.router)
app.include_router(activities_router.ui_router)
app.include_router(epochs_router.router)
app.include_router(freezes_router.router)
app.include_router(rollback_router.router)
Expand Down
4 changes: 3 additions & 1 deletion src/soa_builder/web/initialize_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ def _init_db():
study_cell_uid TEXT NOT NULL, --immutable StudyCell_N identifier unique within SOA
arm_uid TEXT NOT NULL,
epoch_uid TEXT NOT NULL,
element_uid TEXT NOT NULL
element_uid TEXT NOT NULL,
order_index INTEGER,
UNIQUE(soa_id, study_cell_uid)
)"""
)

Expand Down
20 changes: 20 additions & 0 deletions src/soa_builder/web/migrate_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,26 @@ def _migrate_activity_concept_add_href():
logger.warning("activity_concept href migration failed: %s", e)


def _migrate_activity_concept_add_dss():
"""Add dss_title and dss_href columns to activity_concept for DSS assignment."""
try:
conn = _connect()
cur = conn.cursor()
cur.execute("PRAGMA table_info(activity_concept)")
cols = {r[1] for r in cur.fetchall()}
if "dss_title" not in cols:
cur.execute("ALTER TABLE activity_concept ADD COLUMN dss_title TEXT")
conn.commit()
logger.info("Added dss_title column to activity_concept table")
if "dss_href" not in cols:
cur.execute("ALTER TABLE activity_concept ADD COLUMN dss_href TEXT")
conn.commit()
logger.info("Added dss_href column to activity_concept table")
conn.close()
except Exception as e:
logger.warning("activity_concept dss migration failed: %s", e)


def _migrate_study_cell_add_order_index():
"""Add order_index column to study_cell table to support reordering"""
try:
Expand Down
Loading