Add import_group columns for OSM data tables

This commit is contained in:
Paul Bienkowski 2023-03-26 13:01:30 +02:00
parent 276a2ddc69
commit 69d7f64ead
2 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,39 @@
"""add import groups
Revision ID: b8b0fbae50a4
Revises: 5c7755ead95d
Create Date: 2023-03-26 09:41:36.621203
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "b8b0fbae50a4"
down_revision = "5c7755ead95d"
branch_labels = None
depends_on = None
def upgrade():
op.add_column(
"road",
sa.Column("import_group", sa.String(), nullable=True),
)
op.add_column(
"region",
sa.Column("import_group", sa.String(), nullable=True),
)
# Set existing to "osm2pgsql"
road = sa.table("road", sa.column("import_group", sa.String))
op.execute(road.update().values(import_group="osm2pgsql"))
region = sa.table("region", sa.column("import_group", sa.String))
op.execute(region.update().values(import_group="osm2pgsql"))
def downgrade():
op.drop_column("road", "import_group")
op.drop_column("region", "import_group")

View file

@ -140,6 +140,7 @@ class Road(Base):
geometry = Column(Geometry)
directionality = Column(Integer)
oneway = Column(Boolean)
import_group = Column(String)
def to_dict(self):
return {
@ -475,6 +476,7 @@ class Region(Base):
name = Column(String)
geometry = Column(Geometry)
admin_level = Column(Integer)
import_group = Column(String)
Comment.author = relationship("User", back_populates="authored_comments")