fix region DB schema

This commit is contained in:
Paul Bienkowski 2022-07-25 17:46:58 +02:00
parent 908093dd6f
commit e38bc9bd76
2 changed files with 21 additions and 6 deletions

View file

@ -22,13 +22,12 @@ def upgrade():
op.create_table(
"region",
sa.Column(
"way_id", sa.BIGINT, autoincrement=True, primary_key=True, index=True
"relation_id", sa.BIGINT, autoincrement=True, primary_key=True, index=True
),
sa.Column("zone", dbtype("zone_type")),
sa.Column("name", sa.String),
sa.Column("geometry", dbtype("GEOMETRY"), index=True),
sa.Column("directionality", sa.Integer),
sa.Column("oenway", sa.Boolean),
sa.Column("admin_level", sa.Integer, index=True),
sa.Column("tags", dbtype("HSTORE")),
)

View file

@ -401,9 +401,22 @@ class Comment(Base):
}
class Region(Base):
__tablename__ = "region"
relation_id = Column(BIGINT, primary_key=True, index=True)
name = Column(String)
geometry = Column(Geometry)
admin_level = Column(Integer)
tags = Column(HSTORE)
Comment.author = relationship("User", back_populates="authored_comments")
User.authored_comments = relationship(
"Comment", order_by=Comment.created_at, back_populates="author", passive_deletes=True
"Comment",
order_by=Comment.created_at,
back_populates="author",
passive_deletes=True,
)
Track.author = relationship("User", back_populates="authored_tracks")
@ -418,7 +431,10 @@ Track.comments = relationship(
OvertakingEvent.track = relationship("Track", back_populates="overtaking_events")
Track.overtaking_events = relationship(
"OvertakingEvent", order_by=OvertakingEvent.time, back_populates="track", passive_deletes=True
"OvertakingEvent",
order_by=OvertakingEvent.time,
back_populates="track",
passive_deletes=True,
)