diff --git a/api/migrations/versions/a049e5eb24dd_create_table_region.py b/api/migrations/versions/a049e5eb24dd_create_table_region.py new file mode 100644 index 0000000..7e50667 --- /dev/null +++ b/api/migrations/versions/a049e5eb24dd_create_table_region.py @@ -0,0 +1,35 @@ +"""create table region + +Revision ID: a049e5eb24dd +Revises: a9627f63fbed +Create Date: 2022-04-02 21:28:43.124521 + +""" +from alembic import op +import sqlalchemy as sa + +from migrations.utils import dbtype + + +# revision identifiers, used by Alembic. +revision = "a049e5eb24dd" +down_revision = "a9627f63fbed" +branch_labels = None +depends_on = None + + +def upgrade(): + op.create_table( + "region", + sa.Column( + "relation_id", sa.BIGINT, autoincrement=True, primary_key=True, index=True + ), + sa.Column("name", sa.String), + sa.Column("geometry", dbtype("GEOMETRY"), index=True), + sa.Column("admin_level", sa.Integer, index=True), + sa.Column("tags", dbtype("HSTORE")), + ) + + +def downgrade(): + op.drop_table("region") diff --git a/api/obs/api/db.py b/api/obs/api/db.py index 64d8e50..f7716a6 100644 --- a/api/obs/api/db.py +++ b/api/obs/api/db.py @@ -432,6 +432,16 @@ 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",