Skip to content
70 changes: 70 additions & 0 deletions alembic/versions/1d2c3b4a5e67_create_nma_stratigraphy_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"""Create legacy NMA_Stratigraphy table.

Revision ID: 1d2c3b4a5e67
Revises: a7b8c9d0e1f2
Create Date: 2026-01-15 00:00:00.000000
"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from sqlalchemy import inspect
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "1d2c3b4a5e67"
down_revision: Union[str, Sequence[str], None] = "f5a6b7c8d9e0"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
"""Create the legacy stratigraphy table."""
bind = op.get_bind()
inspector = inspect(bind)
if inspector.has_table("NMA_Stratigraphy"):
return

op.create_table(
"NMA_Stratigraphy",
sa.Column(
"GlobalID",
postgresql.UUID(as_uuid=True),
primary_key=True,
nullable=False,
),
sa.Column("WellID", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("PointID", sa.String(length=10), nullable=False),
sa.Column(
"thing_id",
sa.Integer(),
sa.ForeignKey("thing.id", ondelete="CASCADE"),
nullable=False,
),
sa.Column("StratTop", sa.Float(), nullable=True),
sa.Column("StratBottom", sa.Float(), nullable=True),
sa.Column("UnitIdentifier", sa.String(length=50), nullable=True),
sa.Column("Lithology", sa.String(length=100), nullable=True),
sa.Column("LithologicModifier", sa.String(length=100), nullable=True),
sa.Column("ContributingUnit", sa.String(length=10), nullable=True),
sa.Column("StratSource", sa.Text(), nullable=True),
sa.Column("StratNotes", sa.Text(), nullable=True),
sa.Column("OBJECTID", sa.Integer(), nullable=True, unique=True),
)
op.create_index(
"ix_nma_stratigraphy_point_id",
"NMA_Stratigraphy",
["PointID"],
)
op.create_index(
"ix_nma_stratigraphy_thing_id",
"NMA_Stratigraphy",
["thing_id"],
)


def downgrade() -> None:
op.drop_index("ix_nma_stratigraphy_thing_id", table_name="NMA_Stratigraphy")
op.drop_index("ix_nma_stratigraphy_point_id", table_name="NMA_Stratigraphy")
op.drop_table("NMA_Stratigraphy")
56 changes: 56 additions & 0 deletions alembic/versions/c2f4a9d0b1e2_create_nma_associated_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Create legacy NMA_AssociatedData table.

Revision ID: c2f4a9d0b1e2
Revises: a7b8c9d0e1f2
Create Date: 2026-03-05 00:00:00.000000
"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from sqlalchemy import inspect
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "c2f4a9d0b1e2"
down_revision: Union[str, Sequence[str], None] = "a7b8c9d0e1f2"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
"""Create the legacy associated data table."""
bind = op.get_bind()
inspector = inspect(bind)
if not inspector.has_table("NMA_AssociatedData"):
op.create_table(
"NMA_AssociatedData",
sa.Column("LocationId", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("PointID", sa.String(length=10), nullable=True),
sa.Column(
"AssocID",
postgresql.UUID(as_uuid=True),
nullable=False,
primary_key=True,
),
sa.Column("Notes", sa.String(length=255), nullable=True),
sa.Column("Formation", sa.String(length=15), nullable=True),
sa.Column("OBJECTID", sa.Integer(), nullable=True, unique=True),
sa.Column(
"thing_id",
sa.Integer(),
sa.ForeignKey("thing.id", ondelete="CASCADE"),
nullable=True,
),
sa.UniqueConstraint("LocationId", name="AssociatedData$LocationId"),
)
op.create_index("AssociatedData$PointID", "NMA_AssociatedData", ["PointID"])


def downgrade() -> None:
"""Drop the legacy associated data table."""
bind = op.get_bind()
inspector = inspect(bind)
if inspector.has_table("NMA_AssociatedData"):
op.drop_table("NMA_AssociatedData")
53 changes: 53 additions & 0 deletions alembic/versions/d3a4b5c6d7e8_create_nma_surface_water_photos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Create legacy NMA_SurfaceWaterPhotos table.

Revision ID: d3a4b5c6d7e8
Revises: c2f4a9d0b1e2
Create Date: 2026-03-05 00:00:00.000000
"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from sqlalchemy import inspect
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "d3a4b5c6d7e8"
down_revision: Union[str, Sequence[str], None] = "c2f4a9d0b1e2"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
"""Create the legacy surface water photos table."""
bind = op.get_bind()
inspector = inspect(bind)
if not inspector.has_table("NMA_SurfaceWaterPhotos"):
op.create_table(
"NMA_SurfaceWaterPhotos",
sa.Column("SurfaceID", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("PointID", sa.String(length=50), nullable=False),
sa.Column("OLEPath", sa.String(length=50), nullable=True),
sa.Column("OBJECTID", sa.Integer(), nullable=True, unique=True),
sa.Column(
"GlobalID",
postgresql.UUID(as_uuid=True),
nullable=False,
primary_key=True,
),
)
op.create_index(
"SurfaceWaterPhotos$PointID", "NMA_SurfaceWaterPhotos", ["PointID"]
)
op.create_index(
"SurfaceWaterPhotos$SurfaceID", "NMA_SurfaceWaterPhotos", ["SurfaceID"]
)


def downgrade() -> None:
"""Drop the legacy surface water photos table."""
bind = op.get_bind()
inspector = inspect(bind)
if inspector.has_table("NMA_SurfaceWaterPhotos"):
op.drop_table("NMA_SurfaceWaterPhotos")
49 changes: 49 additions & 0 deletions alembic/versions/e4b5c6d7e8f9_create_nma_weather_photos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""Create legacy NMA_WeatherPhotos table.

Revision ID: e4b5c6d7e8f9
Revises: d3a4b5c6d7e8
Create Date: 2026-03-05 00:00:00.000000
"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from sqlalchemy import inspect
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "e4b5c6d7e8f9"
down_revision: Union[str, Sequence[str], None] = "d3a4b5c6d7e8"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
"""Create the legacy weather photos table."""
bind = op.get_bind()
inspector = inspect(bind)
if not inspector.has_table("NMA_WeatherPhotos"):
op.create_table(
"NMA_WeatherPhotos",
sa.Column("WeatherID", postgresql.UUID(as_uuid=True), nullable=True),
sa.Column("PointID", sa.String(length=50), nullable=False),
sa.Column("OLEPath", sa.String(length=50), nullable=True),
sa.Column("OBJECTID", sa.Integer(), nullable=True, unique=True),
sa.Column(
"GlobalID",
postgresql.UUID(as_uuid=True),
nullable=False,
primary_key=True,
),
)
op.create_index("WeatherPhotos$PointID", "NMA_WeatherPhotos", ["PointID"])
op.create_index("WeatherPhotos$WeatherID", "NMA_WeatherPhotos", ["WeatherID"])


def downgrade() -> None:
"""Drop the legacy weather photos table."""
bind = op.get_bind()
inspector = inspect(bind)
if inspector.has_table("NMA_WeatherPhotos"):
op.drop_table("NMA_WeatherPhotos")
52 changes: 52 additions & 0 deletions alembic/versions/f5a6b7c8d9e0_create_nma_soil_rock_results.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""Create legacy NMA_Soil_Rock_Results table.

Revision ID: f5a6b7c8d9e0
Revises: e4b5c6d7e8f9
Create Date: 2026-03-05 00:00:00.000000
"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op
from sqlalchemy import inspect

# revision identifiers, used by Alembic.
revision: str = "f5a6b7c8d9e0"
down_revision: Union[str, Sequence[str], None] = "e4b5c6d7e8f9"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
"""Create the legacy soil/rock results table."""
bind = op.get_bind()
inspector = inspect(bind)
if not inspector.has_table("NMA_Soil_Rock_Results"):
op.create_table(
"NMA_Soil_Rock_Results",
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
sa.Column("Point_ID", sa.String(length=255), nullable=True),
sa.Column("Sample Type", sa.String(length=255), nullable=True),
sa.Column("Date Sampled", sa.String(length=255), nullable=True),
sa.Column("d13C", sa.Float(), nullable=True),
sa.Column("d18O", sa.Float(), nullable=True),
sa.Column("Sampled by", sa.String(length=255), nullable=True),
sa.Column(
"thing_id",
sa.Integer(),
sa.ForeignKey("thing.id", ondelete="CASCADE"),
nullable=True,
),
)
op.create_index(
"Soil_Rock_Results$Point_ID", "NMA_Soil_Rock_Results", ["Point_ID"]
)


def downgrade() -> None:
"""Drop the legacy soil/rock results table."""
bind = op.get_bind()
inspector = inspect(bind)
if inspector.has_table("NMA_Soil_Rock_Results"):
op.drop_table("NMA_Soil_Rock_Results")
Loading
Loading