Skip to content

Commit

Permalink
WIP: add population + area fields with 0 as default
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaupetit committed Sep 5, 2024
1 parent 2aeae47 commit 30b6d2a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""admin_level_add_population_area
Revision ID: b10e85cde5d0
Revises: d198170d222f
Create Date: 2024-09-05 15:11:38.628739
"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa

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


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"city",
sa.Column("population", sa.Integer(), nullable=False, server_default="0"),
)
op.add_column(
"city", sa.Column("area", sa.Float(), nullable=False, server_default="0.0")
)
op.add_column(
"department",
sa.Column("population", sa.Integer(), nullable=False, server_default="0"),
)
op.add_column(
"department",
sa.Column("area", sa.Float(), nullable=False, server_default="0.0"),
)
op.add_column(
"epci",
sa.Column("population", sa.Integer(), nullable=False, server_default="0"),
)
op.add_column(
"epci", sa.Column("area", sa.Float(), nullable=False, server_default="0.0")
)
op.add_column(
"region",
sa.Column("population", sa.Integer(), nullable=False, server_default="0"),
)
op.add_column(
"region", sa.Column("area", sa.Float(), nullable=False, server_default="0.0")
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("region", "area")
op.drop_column("region", "population")
op.drop_column("epci", "area")
op.drop_column("epci", "population")
op.drop_column("department", "area")
op.drop_column("department", "population")
op.drop_column("city", "area")
op.drop_column("city", "population")
# ### end Alembic commands ###
2 changes: 2 additions & 0 deletions src/api/qualicharge/schemas/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class BaseAdministrativeBoundaries(BaseTimestampedSQLModel):
spatial_index=True,
)
) # type: ignore[call-overload]
population: int = 0
area: float = 0.0


class Region(BaseAdministrativeBoundaries, table=True):
Expand Down

0 comments on commit 30b6d2a

Please sign in to comment.