endpoint setup

This commit is contained in:
exolonConfidental
2026-02-08 11:18:47 +05:30
parent 8fb3b7cf67
commit a77788fc47
33 changed files with 932 additions and 352 deletions

View File

@@ -0,0 +1,73 @@
"""add geom column
Revision ID: b7538fce8343
Revises: 6cd12cae8c96
Create Date: 2026-02-07 14:33:51.832269
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from geoalchemy2 import Geography
# revision identifiers, used by Alembic.
revision: str = 'b7538fce8343'
down_revision: Union[str, Sequence[str], None] = '6cd12cae8c96'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
# op.drop_table('layer')
# op.drop_table('spatial_ref_sys')
# op.drop_table('topology')
op.add_column('locations', sa.Column('geom',Geography(geometry_type='POINT', srid=4326, dimension=2, from_text='ST_GeogFromText', name='geography', nullable=False), nullable=False))
op.execute(
"CREATE INDEX IF NOT EXISTS idx_locations_geom ON locations USING gist (geom);"
)
op.create_unique_constraint('uq_osm_location', 'locations', ['osm_type', 'osm_id'])
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('uq_osm_location', 'locations', type_='unique')
op.drop_index('idx_locations_geom', table_name='locations', postgresql_using='gist')
op.drop_column('locations', 'geom')
# op.create_table('topology',
# sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
# sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
# sa.Column('srid', sa.INTEGER(), autoincrement=False, nullable=False),
# sa.Column('precision', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False),
# sa.Column('hasz', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False),
# sa.Column('useslargeids', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False),
# sa.PrimaryKeyConstraint('id', name=op.f('topology_pkey')),
# sa.UniqueConstraint('name', name=op.f('topology_name_key'), postgresql_include=[], postgresql_nulls_not_distinct=False)
# )
# 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=op.f('spatial_ref_sys_srid_check')),
# sa.PrimaryKeyConstraint('srid', name=op.f('spatial_ref_sys_pkey'))
# )
# op.create_table('layer',
# sa.Column('topology_id', sa.INTEGER(), autoincrement=False, nullable=False),
# sa.Column('layer_id', sa.INTEGER(), autoincrement=False, nullable=False),
# sa.Column('schema_name', sa.VARCHAR(), autoincrement=False, nullable=False),
# sa.Column('table_name', sa.VARCHAR(), autoincrement=False, nullable=False),
# sa.Column('feature_column', sa.VARCHAR(), autoincrement=False, nullable=False),
# sa.Column('feature_type', sa.INTEGER(), autoincrement=False, nullable=False),
# sa.Column('level', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=False),
# sa.Column('child_id', sa.INTEGER(), autoincrement=False, nullable=True),
# sa.ForeignKeyConstraint(['topology_id'], ['topology.id'], name=op.f('layer_topology_id_fkey')),
# sa.PrimaryKeyConstraint('topology_id', 'layer_id', name=op.f('layer_pkey')),
# sa.UniqueConstraint('schema_name', 'table_name', 'feature_column', name=op.f('layer_schema_name_table_name_feature_column_key'), postgresql_include=[], postgresql_nulls_not_distinct=False)
# )
# ### end Alembic commands ###