Create Region table
This commit is contained in:
parent
9e80113089
commit
ec53591ce0
35
api/migrations/versions/a049e5eb24dd_create_table_region.py
Normal file
35
api/migrations/versions/a049e5eb24dd_create_table_region.py
Normal file
|
@ -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")
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue