Skip to content

Commit

Permalink
Squash database migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaupetit committed Jul 29, 2024
1 parent 250d7ec commit 06e26df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 364 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
"""add geo models
"""add admin geo boundaries
Revision ID: d4dc82e07410
Revision ID: 7b8c33d8399d
Revises: b5ef0fba88a7
Create Date: 2024-07-24 15:27:22.779483
Create Date: 2024-07-29 08:57:49.939396
"""

from typing import Sequence, Union

from alembic import op
import geoalchemy2
import sqlalchemy as sa
import sqlmodel

from alembic import op
from sqlalchemy.dialects import postgresql


# revision identifiers, used by Alembic.
revision: str = "d4dc82e07410"
revision: str = "7b8c33d8399d"
down_revision: Union[str, None] = "b5ef0fba88a7"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
Expand All @@ -32,13 +29,9 @@ def upgrade() -> None:
sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column(
"geom",
"geometry",
geoalchemy2.types.Geometry(
geometry_type="POLYGON",
srid=4326,
from_text="ST_GeomFromEWKT",
name="geometry",
nullable=False,
srid=4326, from_text="ST_GeomFromEWKT", name="geometry", nullable=False
),
nullable=False,
),
Expand All @@ -54,13 +47,9 @@ def upgrade() -> None:
sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column(
"geom",
"geometry",
geoalchemy2.types.Geometry(
geometry_type="POLYGON",
srid=4326,
from_text="ST_GeomFromEWKT",
name="geometry",
nullable=False,
srid=4326, from_text="ST_GeomFromEWKT", name="geometry", nullable=False
),
nullable=False,
),
Expand All @@ -76,13 +65,9 @@ def upgrade() -> None:
sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column(
"geom",
"geometry",
geoalchemy2.types.Geometry(
geometry_type="POLYGON",
srid=4326,
from_text="ST_GeomFromEWKT",
name="geometry",
nullable=False,
srid=4326, from_text="ST_GeomFromEWKT", name="geometry", nullable=False
),
nullable=False,
),
Expand All @@ -103,13 +88,9 @@ def upgrade() -> None:
sa.Column("id", sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column(
"geom",
"geometry",
geoalchemy2.types.Geometry(
geometry_type="POLYGON",
srid=4326,
from_text="ST_GeomFromEWKT",
name="geometry",
nullable=False,
srid=4326, from_text="ST_GeomFromEWKT", name="geometry", nullable=False
),
nullable=False,
),
Expand All @@ -134,17 +115,17 @@ def upgrade() -> None:
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_city_code"), table_name="city")
op.drop_index("idx_city_geom", table_name="city", postgresql_using="gist")
op.drop_index("idx_city_geometry", table_name="city", postgresql_using="gist")
op.drop_table("city")
op.drop_index(op.f("ix_department_code"), table_name="department")
op.drop_index(
"idx_department_geom", table_name="department", postgresql_using="gist"
"idx_department_geometry", table_name="department", postgresql_using="gist"
)
op.drop_table("department")
op.drop_index(op.f("ix_region_code"), table_name="region")
op.drop_index("idx_region_geom", table_name="region", postgresql_using="gist")
op.drop_index("idx_region_geometry", table_name="region", postgresql_using="gist")
op.drop_table("region")
op.drop_index(op.f("ix_epci_code"), table_name="epci")
op.drop_index("idx_epci_geom", table_name="epci", postgresql_using="gist")
op.drop_index("idx_epci_geometry", table_name="epci", postgresql_using="gist")
op.drop_table("epci")
# ### end Alembic commands ###
Loading

0 comments on commit 06e26df

Please sign in to comment.