Add import_group columns for OSM data tables
This commit is contained in:
parent
276a2ddc69
commit
69d7f64ead
39
api/migrations/versions/b8b0fbae50a4_add_import_groups.py
Normal file
39
api/migrations/versions/b8b0fbae50a4_add_import_groups.py
Normal 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")
|
|
@ -140,6 +140,7 @@ class Road(Base):
|
||||||
geometry = Column(Geometry)
|
geometry = Column(Geometry)
|
||||||
directionality = Column(Integer)
|
directionality = Column(Integer)
|
||||||
oneway = Column(Boolean)
|
oneway = Column(Boolean)
|
||||||
|
import_group = Column(String)
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return {
|
return {
|
||||||
|
@ -475,6 +476,7 @@ class Region(Base):
|
||||||
name = Column(String)
|
name = Column(String)
|
||||||
geometry = Column(Geometry)
|
geometry = Column(Geometry)
|
||||||
admin_level = Column(Integer)
|
admin_level = Column(Integer)
|
||||||
|
import_group = Column(String)
|
||||||
|
|
||||||
|
|
||||||
Comment.author = relationship("User", back_populates="authored_comments")
|
Comment.author = relationship("User", back_populates="authored_comments")
|
||||||
|
|
Loading…
Reference in a new issue