From dc8632d1506fc82098a099418033e1618a20313a Mon Sep 17 00:00:00 2001 From: jakeross Date: Wed, 28 Jan 2026 10:17:17 +1100 Subject: [PATCH 1/4] feat: add legacy equipment fields to deployment schema --- ...63109252fb1_add_legacy_equipment_fields.py | 46 +++++++++++++++++++ db/deployment.py | 7 +++ transfers/sensor_transfer.py | 12 +++++ 3 files changed, 65 insertions(+) create mode 100644 alembic/versions/263109252fb1_add_legacy_equipment_fields.py diff --git a/alembic/versions/263109252fb1_add_legacy_equipment_fields.py b/alembic/versions/263109252fb1_add_legacy_equipment_fields.py new file mode 100644 index 000000000..a1fdd09b7 --- /dev/null +++ b/alembic/versions/263109252fb1_add_legacy_equipment_fields.py @@ -0,0 +1,46 @@ +"""add legacy equipment fields + +Revision ID: 263109252fb1 +Revises: c1d2e3f4a5b6 +Create Date: 2026-01-28 10:05:10.122531 + +""" + +from typing import Sequence, Union + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "263109252fb1" +down_revision: Union[str, Sequence[str], None] = "c1d2e3f4a5b6" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None +FIELDS = ( + "WI_Duration", + "WI_EndFrequency", + "WI_Magnitude", + "WI_MicGain", + "WI_MinSoundDepth", + "WI_StartFrequency", +) + + +def upgrade() -> None: + """Upgrade schema.""" + + for field in FIELDS: + op.add_column( + "deployment", + sa.Column( + f"nma_{field}", + sa.Integer(), + nullable=True, + ), + ) + + +def downgrade() -> None: + """Downgrade schema.""" + for field in FIELDS: + op.drop_column("deployment", f"nma_{field}") diff --git a/db/deployment.py b/db/deployment.py index 0b2dc61df..20c4e8651 100644 --- a/db/deployment.py +++ b/db/deployment.py @@ -46,6 +46,13 @@ class Deployment(Base, AutoBaseMixin, ReleaseMixin): hanging_point_description: Mapped[str] = mapped_column(Text, nullable=True) notes: Mapped[str] = mapped_column(Text, nullable=True) + nma_WI_Duration: Mapped[int] = mapped_column(Integer, nullable=True) + nma_WI_EndFrequency: Mapped[int] = mapped_column(Integer, nullable=True) + nma_WI_Magnitude: Mapped[int] = mapped_column(Integer, nullable=True) + nma_WI_MicGain: Mapped[int] = mapped_column(Integer, nullable=True) + nma_WI_MinSoundDepth: Mapped[int] = mapped_column(Integer, nullable=True) + nma_WI_StartFrequency: Mapped[int] = mapped_column(Integer, nullable=True) + # --- Relationships --- # Many-To-One: A Deployment is for one Thing. thing: Mapped["Thing"] = relationship("Thing", back_populates="deployments") diff --git a/transfers/sensor_transfer.py b/transfers/sensor_transfer.py index 3a39a1a03..ded7174ec 100644 --- a/transfers/sensor_transfer.py +++ b/transfers/sensor_transfer.py @@ -118,6 +118,12 @@ def _group_step(self, session: Session, row: pd.Series, db_item: Base): serial_no=row.SerialNo, owner_agency="NMBGMR", notes=row.Equipment_Notes, + nma_WI_Duration=row.WI_Duration, + nma_WI_EndFrequency=row.WI_EndFrequency, + nma_WI_Magnitude=row.WI_Magnitude, + nma_WI_MicGain=row.WI_MicGain, + nma_WI_MinSoundDepth=row.WI_MinSoundDepth, + nma_WI_StartFrequency=row.WI_StartFrequency, ) self._added[row.SerialNo] = sensor session.add(sensor) @@ -218,6 +224,12 @@ def _group_step(self, session: Session, row: pd.Series, db_item: Base): hanging_cable_length=row.HangingCableLength, hanging_point_height=row.HangingPointHgt, hanging_point_description=row.HangingPointDescription, + nma_WI_Duration=row.WI_Duration, + nma_WI_EndFrequency=row.WI_EndFrequency, + nma_WI_Magnitude=row.WI_Magnitude, + nma_WI_MicGain=row.WI_MicGain, + nma_WI_MinSoundDepth=row.WI_MinSoundDepth, + nma_WI_StartFrequency=row.WI_StartFrequency, ) session.add(deployment) logger.info( From 4ac2fd6de9032bb7d723e4b0a84433144ecc2fca Mon Sep 17 00:00:00 2001 From: jakeross Date: Wed, 28 Jan 2026 10:21:31 +1100 Subject: [PATCH 2/4] feat: add new fields for wellntel equipment to deployment schema --- admin/views/deployment.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/admin/views/deployment.py b/admin/views/deployment.py index 867655ba8..511b69356 100644 --- a/admin/views/deployment.py +++ b/admin/views/deployment.py @@ -51,6 +51,12 @@ class DeploymentAdmin(OcotilloModelView): "recording_interval", "release_status", "created_at", + "nma_WI_Duration", + "nma_WI_EndFrequency", + "nma_WI_Magnitude", + "nma_WI_MicGain", + "nma_WI_MinSoundDepth", + "nma_WI_StartFrequency", ] fields_default_sort = [ @@ -65,6 +71,12 @@ class DeploymentAdmin(OcotilloModelView): "recording_interval_units", "release_status", "created_at", + "nma_WI_Duration", + "nma_WI_EndFrequency", + "nma_WI_Magnitude", + "nma_WI_MicGain", + "nma_WI_MinSoundDepth", + "nma_WI_StartFrequency", ] page_size = 50 @@ -85,6 +97,12 @@ class DeploymentAdmin(OcotilloModelView): "hanging_point_height", "hanging_point_description", "notes", + "nma_WI_Duration", + "nma_WI_EndFrequency", + "nma_WI_Magnitude", + "nma_WI_MicGain", + "nma_WI_MinSoundDepth", + "nma_WI_StartFrequency", # Release Status "release_status", # Audit Fields From 9b1ab95d46243b9d278350cfc83ac3971d312eb6 Mon Sep 17 00:00:00 2001 From: jakeross Date: Wed, 28 Jan 2026 10:23:04 +1100 Subject: [PATCH 3/4] feat: remove unused wellntel equipment fields from sensor transfer --- transfers/sensor_transfer.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/transfers/sensor_transfer.py b/transfers/sensor_transfer.py index ded7174ec..91d5f8475 100644 --- a/transfers/sensor_transfer.py +++ b/transfers/sensor_transfer.py @@ -118,12 +118,6 @@ def _group_step(self, session: Session, row: pd.Series, db_item: Base): serial_no=row.SerialNo, owner_agency="NMBGMR", notes=row.Equipment_Notes, - nma_WI_Duration=row.WI_Duration, - nma_WI_EndFrequency=row.WI_EndFrequency, - nma_WI_Magnitude=row.WI_Magnitude, - nma_WI_MicGain=row.WI_MicGain, - nma_WI_MinSoundDepth=row.WI_MinSoundDepth, - nma_WI_StartFrequency=row.WI_StartFrequency, ) self._added[row.SerialNo] = sensor session.add(sensor) From 15bb11c5e2948a2b031ebbea013b62292b6d3f60 Mon Sep 17 00:00:00 2001 From: jakeross Date: Thu, 29 Jan 2026 16:16:52 +1100 Subject: [PATCH 4/4] fix: update down_revision for legacy equipment fields migration --- alembic/versions/263109252fb1_add_legacy_equipment_fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alembic/versions/263109252fb1_add_legacy_equipment_fields.py b/alembic/versions/263109252fb1_add_legacy_equipment_fields.py index a1fdd09b7..35d8166b0 100644 --- a/alembic/versions/263109252fb1_add_legacy_equipment_fields.py +++ b/alembic/versions/263109252fb1_add_legacy_equipment_fields.py @@ -13,7 +13,7 @@ # revision identifiers, used by Alembic. revision: str = "263109252fb1" -down_revision: Union[str, Sequence[str], None] = "c1d2e3f4a5b6" +down_revision: Union[str, Sequence[str], None] = "3a9c1f5b7d2e" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None FIELDS = (