eventcally/migrations/versions/091deace5f08_.py
2021-02-12 15:43:40 +01:00

62 lines
1.7 KiB
Python

"""empty message
Revision ID: 091deace5f08
Revises: 6b7016f73688
Create Date: 2020-10-02 09:29:12.932229
"""
import sqlalchemy as sa
from alembic import op
from geoalchemy2.types import Geometry
from sqlalchemy.sql import text
# revision identifiers, used by Alembic.
revision = "091deace5f08"
down_revision = "6b7016f73688"
branch_labels = None
depends_on = None
def upgrade():
bind = op.get_bind()
bind.execute(text("create extension if not exists postgis;"))
# ### commands auto generated by Alembic - please adjust! ###
# op.drop_table('spatial_ref_sys')
op.add_column(
"location",
sa.Column(
"coordinate",
Geometry(
geometry_type="POINT", from_text="ST_GeomFromEWKT", name="geometry"
),
nullable=True,
),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("location", "coordinate")
op.create_table(
"spatial_ref_sys",
sa.Column("srid", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column(
"auth_name", sa.VARCHAR(length=256), autoincrement=False, nullable=True
),
sa.Column("auth_srid", sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column(
"srtext", sa.VARCHAR(length=2048), autoincrement=False, nullable=True
),
sa.Column(
"proj4text", sa.VARCHAR(length=2048), autoincrement=False, nullable=True
),
sa.CheckConstraint(
"(srid > 0) AND (srid <= 998999)", name="spatial_ref_sys_srid_check"
),
sa.PrimaryKeyConstraint("srid", name="spatial_ref_sys_pkey"),
)
# ### end Alembic commands ###