Skip to content

Commit e6fdb41

Browse files
committed
feat: create legacy NMA_Stratigraphy table with associated columns and indexes
1 parent 02be9da commit e6fdb41

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
"""Create legacy NMA_Stratigraphy table.
2+
3+
Revision ID: 1d2c3b4a5e67
4+
Revises: a7b8c9d0e1f2
5+
Create Date: 2026-01-15 00:00:00.000000
6+
"""
7+
8+
from typing import Sequence, Union
9+
10+
import sqlalchemy as sa
11+
from alembic import op
12+
from sqlalchemy import inspect
13+
from sqlalchemy.dialects import postgresql
14+
15+
# revision identifiers, used by Alembic.
16+
revision: str = "1d2c3b4a5e67"
17+
down_revision: Union[str, Sequence[str], None] = "f5a6b7c8d9e0"
18+
branch_labels: Union[str, Sequence[str], None] = None
19+
depends_on: Union[str, Sequence[str], None] = None
20+
21+
22+
def upgrade() -> None:
23+
"""Create the legacy stratigraphy table."""
24+
bind = op.get_bind()
25+
inspector = inspect(bind)
26+
if inspector.has_table("NMA_Stratigraphy"):
27+
return
28+
29+
op.create_table(
30+
"NMA_Stratigraphy",
31+
sa.Column(
32+
"GlobalID",
33+
postgresql.UUID(as_uuid=True),
34+
primary_key=True,
35+
nullable=False,
36+
),
37+
sa.Column("WellID", postgresql.UUID(as_uuid=True), nullable=True),
38+
sa.Column("PointID", sa.String(length=10), nullable=False),
39+
sa.Column(
40+
"thing_id",
41+
sa.Integer(),
42+
sa.ForeignKey("thing.id", ondelete="CASCADE"),
43+
nullable=False,
44+
),
45+
sa.Column("StratTop", sa.Float(), nullable=True),
46+
sa.Column("StratBottom", sa.Float(), nullable=True),
47+
sa.Column("UnitIdentifier", sa.String(length=50), nullable=True),
48+
sa.Column("Lithology", sa.String(length=100), nullable=True),
49+
sa.Column("LithologicModifier", sa.String(length=100), nullable=True),
50+
sa.Column("ContributingUnit", sa.String(length=10), nullable=True),
51+
sa.Column("StratSource", sa.Text(), nullable=True),
52+
sa.Column("StratNotes", sa.Text(), nullable=True),
53+
sa.Column("OBJECTID", sa.Integer(), nullable=True, unique=True),
54+
)
55+
op.create_index(
56+
"ix_nma_stratigraphy_point_id",
57+
"NMA_Stratigraphy",
58+
["PointID"],
59+
)
60+
op.create_index(
61+
"ix_nma_stratigraphy_thing_id",
62+
"NMA_Stratigraphy",
63+
["thing_id"],
64+
)
65+
66+
67+
def downgrade() -> None:
68+
op.drop_index("ix_nma_stratigraphy_thing_id", table_name="NMA_Stratigraphy")
69+
op.drop_index("ix_nma_stratigraphy_point_id", table_name="NMA_Stratigraphy")
70+
op.drop_table("NMA_Stratigraphy")

0 commit comments

Comments
 (0)