From d8a4dc9d319afbf0ac20c13b4ed7c112fd011124 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 05:00:49 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/backend/app/db/db_models.py | 1 + src/backend/app/main.py | 2 +- src/backend/app/migrations/alembic_helpers.py | 19 +- src/backend/app/migrations/env.py | 7 +- .../ec28a415c8d8_create_inital_tables.py | 2976 ++++++++++++----- 5 files changed, 2143 insertions(+), 862 deletions(-) diff --git a/src/backend/app/db/db_models.py b/src/backend/app/db/db_models.py index 2eadb2cd8e..77483eefad 100644 --- a/src/backend/app/db/db_models.py +++ b/src/backend/app/db/db_models.py @@ -55,6 +55,7 @@ UserRole, ValidationPermission, ) + from .database import Base, FmtmMetadata from .postgis_utils import timestamp diff --git a/src/backend/app/main.py b/src/backend/app/main.py index baadf77ceb..2cd346f6dc 100644 --- a/src/backend/app/main.py +++ b/src/backend/app/main.py @@ -33,7 +33,7 @@ from .auth import auth_routes from .central import central_routes from .config import settings -from .db.database import Base, engine, get_db +from .db.database import get_db from .organization import organization_routes from .projects import project_routes from .projects.project_crud import read_xlsforms diff --git a/src/backend/app/migrations/alembic_helpers.py b/src/backend/app/migrations/alembic_helpers.py index 1ba35df0d1..773b6eeb0c 100644 --- a/src/backend/app/migrations/alembic_helpers.py +++ b/src/backend/app/migrations/alembic_helpers.py @@ -1,23 +1,26 @@ from alembic import op from sqlalchemy import engine_from_config from sqlalchemy.engine import reflection - + + def table_does_not_exist(table, schema=None): config = op.get_context().config engine = engine_from_config( - config.get_section(config.config_ini_section), prefix='sqlalchemy.') + config.get_section(config.config_ini_section), prefix="sqlalchemy." + ) insp = reflection.Inspector.from_engine(engine) - return insp.has_table(table, schema) == False - - + return insp.has_table(table, schema) is False + + def table_has_column(table, column): config = op.get_context().config engine = engine_from_config( - config.get_section(config.config_ini_section), prefix='sqlalchemy.') + config.get_section(config.config_ini_section), prefix="sqlalchemy." + ) insp = reflection.Inspector.from_engine(engine) has_column = False for col in insp.get_columns(table): - if column not in col['name']: + if column not in col["name"]: continue has_column = True - return has_column \ No newline at end of file + return has_column diff --git a/src/backend/app/migrations/env.py b/src/backend/app/migrations/env.py index d6cb034375..6fa3d55538 100644 --- a/src/backend/app/migrations/env.py +++ b/src/backend/app/migrations/env.py @@ -1,10 +1,10 @@ from logging.config import fileConfig -from alembic import op + from alembic import context from config import settings +from db.db_models import Base from geoalchemy2 import alembic_helpers from sqlalchemy import engine_from_config, pool -from db.db_models import Base config = context.config config.set_main_option("sqlalchemy.url", settings.FMTM_DB_URL) @@ -18,6 +18,7 @@ exclude_tables = config.get_section("alembic:exclude").get("tables", "").split(",") + def include_object(object, name, type_, reflected, compare_to): """Custom helper function that enables us to ignore our excluded tables in the autogen sweep.""" if type_ == "table" and name in exclude_tables: @@ -80,4 +81,4 @@ def run_migrations_online() -> None: if context.is_offline_mode(): run_migrations_offline() else: - run_migrations_online() \ No newline at end of file + run_migrations_online() diff --git a/src/backend/app/migrations/versions/ec28a415c8d8_create_inital_tables.py b/src/backend/app/migrations/versions/ec28a415c8d8_create_inital_tables.py index 416de9dd61..8aa8382f5a 100644 --- a/src/backend/app/migrations/versions/ec28a415c8d8_create_inital_tables.py +++ b/src/backend/app/migrations/versions/ec28a415c8d8_create_inital_tables.py @@ -1,22 +1,25 @@ -"""create inital tables +"""create inital tables. Revision ID: ec28a415c8d8 -Revises: +Revises: Create Date: 2023-09-26 09:04:00.676103 """ import imp import os -from alembic import op + +import geoalchemy2 import sqlalchemy as sa +from alembic import op from sqlalchemy.dialects import postgresql -import geoalchemy2 -alembic_helpers = imp.load_source('alembic_helpers', ( - os.getcwd() + '/' + op.get_context().script.dir + '/alembic_helpers.py')) +alembic_helpers = imp.load_source( + "alembic_helpers", + (os.getcwd() + "/" + op.get_context().script.dir + "/alembic_helpers.py"), +) # revision identifiers, used by Alembic. -revision = 'ec28a415c8d8' +revision = "ec28a415c8d8" down_revision = None branch_labels = None depends_on = None @@ -24,771 +27,2016 @@ def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### - if(alembic_helpers.table_does_not_exist('loader_platform')): - op.create_table('loader_platform', - sa.Column('os', sa.VARCHAR(length=50), autoincrement=False, nullable=False), - sa.Column('declare_sect', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('pgbin', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('wget', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('unzip_command', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('psql', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('path_sep', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('loader', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('environ_set_command', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('county_process_command', sa.TEXT(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('os', name='loader_platform_pkey') - ) - - if(alembic_helpers.table_does_not_exist('dumpedpoints')): - op.create_table('dumpedpoints', - sa.Column('osm_id', sa.VARCHAR(), autoincrement=False, nullable=True), - sa.Column('polyid', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('cid', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('clusteruid', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('geom', geoalchemy2.types.Geometry(geometry_type='POINT', srid=4326, from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True) - ) - op.create_index('dumpedpoints_idx', 'dumpedpoints', ['geom'], unique=False, postgresql_using='gist') - - if(alembic_helpers.table_does_not_exist('pagc_lex')): - op.create_table('pagc_lex', - sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('seq', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('word', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('stdword', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('token', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('is_custom', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False), - sa.PrimaryKeyConstraint('id', name='pagc_lex_pkey') - ) - - if(alembic_helpers.table_does_not_exist('zip_lookup_all')): - op.create_table('zip_lookup_all', - sa.Column('zip', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('st_code', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('state', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('co_code', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('county', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.Column('cs_code', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('cousub', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.Column('pl_code', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('place', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.Column('cnt', sa.INTEGER(), autoincrement=False, nullable=True) - ) - - if(alembic_helpers.table_does_not_exist('pagc_rules')): - op.create_table('pagc_rules', - sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('rule', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('is_custom', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', name='pagc_rules_pkey') - ) - - if(alembic_helpers.table_does_not_exist('addrfeat')): - op.create_table('addrfeat', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('tlid', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=False), - sa.Column('aridl', sa.VARCHAR(length=22), autoincrement=False, nullable=True), - sa.Column('aridr', sa.VARCHAR(length=22), autoincrement=False, nullable=True), - sa.Column('linearid', sa.VARCHAR(length=22), autoincrement=False, nullable=True), - sa.Column('fullname', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('lfromhn', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('ltohn', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('rfromhn', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('rtohn', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('zipl', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('zipr', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('edge_mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('parityl', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('parityr', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('plus4l', sa.VARCHAR(length=4), autoincrement=False, nullable=True), - sa.Column('plus4r', sa.VARCHAR(length=4), autoincrement=False, nullable=True), - sa.Column('lfromtyp', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('ltotyp', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('rfromtyp', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('rtotyp', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('offsetl', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('offsetr', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.CheckConstraint("geometrytype(the_geom) = 'LINESTRING'::text OR the_geom IS NULL", name='enforce_geotype_the_geom'), - sa.CheckConstraint('st_ndims(the_geom) = 2', name='enforce_dims_the_geom'), - sa.CheckConstraint('st_srid(the_geom) = 4269', name='enforce_srid_the_geom'), - sa.PrimaryKeyConstraint('gid', name='addrfeat_pkey') - ) - op.create_index('idx_addrfeat_zipr', 'addrfeat', ['zipr'], unique=False) - op.create_index('idx_addrfeat_zipl', 'addrfeat', ['zipl'], unique=False) - op.create_index('idx_addrfeat_tlid', 'addrfeat', ['tlid'], unique=False) - op.create_index('idx_addrfeat_geom_gist', 'addrfeat', ['the_geom'], unique=False, postgresql_using='gist') - - if(alembic_helpers.table_does_not_exist('topology')): - op.create_table('topology', - sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('topology_id_seq'::regclass)"), 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.PrimaryKeyConstraint('id', name='topology_pkey'), - sa.UniqueConstraint('name', name='topology_name_key'), - postgresql_ignore_search_path=False - ) - - if(alembic_helpers.table_does_not_exist('featnames')): - op.create_table('featnames', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('tlid', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('fullname', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('predirabrv', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('pretypabrv', sa.VARCHAR(length=50), autoincrement=False, nullable=True), - sa.Column('prequalabr', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('sufdirabrv', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('suftypabrv', sa.VARCHAR(length=50), autoincrement=False, nullable=True), - sa.Column('sufqualabr', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('predir', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('pretyp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('prequal', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('sufdir', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('suftyp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('sufqual', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('linearid', sa.VARCHAR(length=22), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('paflag', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('gid', name='featnames_pkey') - ) - op.create_index('idx_tiger_featnames_tlid_statefp', 'featnames', ['tlid', 'statefp'], unique=False) - op.create_index('idx_tiger_featnames_snd_name', 'featnames', [sa.text('soundex(name::text)')], unique=False) - op.create_index('idx_tiger_featnames_lname', 'featnames', [sa.text('lower(name::text)')], unique=False) - - if(alembic_helpers.table_does_not_exist('buildings')): - op.create_table('buildings', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('project_id', sa.VARCHAR(), autoincrement=False, nullable=True), - sa.Column('osm_id', sa.VARCHAR(), autoincrement=False, nullable=True), - sa.Column('geom', geoalchemy2.types.Geometry(geometry_type='POLYGON', srid=4326, from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.Column('tags', postgresql.JSONB(astext_type=sa.Text()), autoincrement=False, nullable=True), - sa.Column('polyid', sa.BIGINT(), autoincrement=False, nullable=True) - ) - op.create_index('buildings_idx', 'buildings', ['geom'], unique=False, postgresql_using='gist') - - if(alembic_helpers.table_does_not_exist('zcta5')): - op.create_table('zcta5', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=False), - sa.Column('zcta5ce', sa.VARCHAR(length=5), autoincrement=False, nullable=False), - sa.Column('classfp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('funcstat', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('aland', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('awater', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('intptlat', sa.VARCHAR(length=11), autoincrement=False, nullable=True), - sa.Column('intptlon', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('partflg', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(spatial_index=False, from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.CheckConstraint("geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", name='enforce_geotype_the_geom'), - sa.CheckConstraint('st_ndims(the_geom) = 2', name='enforce_dims_the_geom'), - sa.CheckConstraint('st_srid(the_geom) = 4269', name='enforce_srid_the_geom'), - sa.PrimaryKeyConstraint('zcta5ce', 'statefp', name='pk_tiger_zcta5_zcta5ce'), - sa.UniqueConstraint('gid', name='uidx_tiger_zcta5_gid') - ) - - if(alembic_helpers.table_does_not_exist('secondary_unit_lookup')): - op.create_table('secondary_unit_lookup', - sa.Column('name', sa.VARCHAR(length=20), autoincrement=False, nullable=False), - sa.Column('abbrev', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('name', name='secondary_unit_lookup_pkey') - ) - op.create_index('secondary_unit_lookup_abbrev_idx', 'secondary_unit_lookup', ['abbrev'], unique=False) - - if(alembic_helpers.table_does_not_exist("pagc_gaz")): - op.create_table('pagc_gaz', - sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('seq', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('word', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('stdword', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('token', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('is_custom', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False), - sa.PrimaryKeyConstraint('id', name='pagc_gaz_pkey') - ) - - if(alembic_helpers.table_does_not_exist("direction_lookup")): - op.create_table('direction_lookup', - sa.Column('name', sa.VARCHAR(length=20), autoincrement=False, nullable=False), - sa.Column('abbrev', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('name', name='direction_lookup_pkey') - ) - op.create_index('direction_lookup_abbrev_idx', 'direction_lookup', ['abbrev'], unique=False) - - if(alembic_helpers.table_does_not_exist("state_lookup")): - op.create_table('state_lookup', - sa.Column('st_code', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=40), autoincrement=False, nullable=True), - sa.Column('abbrev', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('statefp', sa.CHAR(length=2), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('st_code', name='state_lookup_pkey'), - sa.UniqueConstraint('abbrev', name='state_lookup_abbrev_key'), - sa.UniqueConstraint('name', name='state_lookup_name_key'), - sa.UniqueConstraint('statefp', name='state_lookup_statefp_key') - ) - - if(alembic_helpers.table_does_not_exist("tabblock20")): - op.create_table('tabblock20', - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('countyfp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('tractce', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('blockce', sa.VARCHAR(length=4), autoincrement=False, nullable=True), - sa.Column('geoid', sa.VARCHAR(length=15), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=10), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('ur', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('uace', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('uatype', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('funcstat', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('aland', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('awater', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('intptlat', sa.VARCHAR(length=11), autoincrement=False, nullable=True), - sa.Column('intptlon', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(geometry_type='MULTIPOLYGON', srid=4269, spatial_index=False, from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.Column('housing', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('pop', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('geoid', name='pk_tabblock20') - ) - - if(alembic_helpers.table_does_not_exist("splitpolygons")): - op.create_table('splitpolygons', - sa.Column('polyid', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('geom', geoalchemy2.types.Geometry(geometry_type='POLYGON', srid=4326, from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.Column('geog', geoalchemy2.types.Geography(from_text='ST_GeogFromText', name='geography'), autoincrement=False, nullable=True), - sa.Column('numfeatures', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('area', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('polyid', name='splitpolygons_pkey') - ) - op.create_index('splitpolygons_idx', 'splitpolygons', ['geom'], unique=False, postgresql_using='gist') - - if(alembic_helpers.table_does_not_exist("cousub")): - op.create_table('cousub', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('countyfp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('cousubfp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('cousubns', sa.VARCHAR(length=8), autoincrement=False, nullable=True), - sa.Column('cosbidfp', sa.VARCHAR(length=10), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('namelsad', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('lsad', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('classfp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('cnectafp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('nectafp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('nctadvfp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('funcstat', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('aland', sa.NUMERIC(precision=14, scale=0), autoincrement=False, nullable=True), - sa.Column('awater', sa.NUMERIC(precision=14, scale=0), autoincrement=False, nullable=True), - sa.Column('intptlat', sa.VARCHAR(length=11), autoincrement=False, nullable=True), - sa.Column('intptlon', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.CheckConstraint("geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", name='enforce_geotype_the_geom'), - sa.CheckConstraint('st_ndims(the_geom) = 2', name='enforce_dims_the_geom'), - sa.CheckConstraint('st_srid(the_geom) = 4269', name='enforce_srid_the_geom'), - sa.PrimaryKeyConstraint('cosbidfp', name='cousub_pkey'), - sa.UniqueConstraint('gid', name='uidx_cousub_gid') - ) - op.create_index('tige_cousub_the_geom_gist', 'cousub', ['the_geom'], unique=False, postgresql_using='gist') - - if(alembic_helpers.table_does_not_exist("zip_state")): - op.create_table('zip_state', - sa.Column('zip', sa.VARCHAR(length=5), autoincrement=False, nullable=False), - sa.Column('stusps', sa.VARCHAR(length=2), autoincrement=False, nullable=False), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('zip', 'stusps', name='zip_state_pkey') - ) - - if(alembic_helpers.table_does_not_exist("place_lookup")): - op.create_table('place_lookup', - sa.Column('st_code', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('state', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('pl_code', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('st_code', 'pl_code', name='place_lookup_pkey') - ) - op.create_index('place_lookup_state_idx', 'place_lookup', ['state'], unique=False) - op.create_index('place_lookup_name_idx', 'place_lookup', [sa.text('soundex(name::text)')], unique=False) - - if(alembic_helpers.table_does_not_exist("lowfeaturecountpolygons")): - op.create_table('lowfeaturecountpolygons', - sa.Column('polyid', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('geom', geoalchemy2.types.Geometry(geometry_type='POLYGON', srid=4326, from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.Column('geog', geoalchemy2.types.Geography(from_text='ST_GeogFromText', name='geography'), autoincrement=False, nullable=True), - sa.Column('numfeatures', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('area', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('n_polyid', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('n_area', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('n_numfeatures', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('sharedbound', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('polyid', name='lowfeaturecountpolygons_pkey') - ) - op.create_index('lowfeaturecountpolygons_idx', 'lowfeaturecountpolygons', ['geom'], unique=False, postgresql_using='gist') - - if(alembic_helpers.table_does_not_exist("place")): - op.create_table('place', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('placefp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('placens', sa.VARCHAR(length=8), autoincrement=False, nullable=True), - sa.Column('plcidfp', sa.VARCHAR(length=7), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('namelsad', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('lsad', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('classfp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('cpi', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('pcicbsa', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('pcinecta', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('funcstat', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('aland', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('awater', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('intptlat', sa.VARCHAR(length=11), autoincrement=False, nullable=True), - sa.Column('intptlon', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.CheckConstraint("geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", name='enforce_geotype_the_geom'), - sa.CheckConstraint('st_ndims(the_geom) = 2', name='enforce_dims_the_geom'), - sa.CheckConstraint('st_srid(the_geom) = 4269', name='enforce_srid_the_geom'), - sa.PrimaryKeyConstraint('plcidfp', name='place_pkey'), - sa.UniqueConstraint('gid', name='uidx_tiger_place_gid') - ) - op.create_index('tiger_place_the_geom_gist', 'place', ['the_geom'], unique=False, postgresql_using='gist') - - if(alembic_helpers.table_does_not_exist("zip_state_loc")): - op.create_table('zip_state_loc', - sa.Column('zip', sa.VARCHAR(length=5), autoincrement=False, nullable=False), - sa.Column('stusps', sa.VARCHAR(length=2), autoincrement=False, nullable=False), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('place', sa.VARCHAR(length=100), autoincrement=False, nullable=False), - sa.PrimaryKeyConstraint('zip', 'stusps', 'place', name='zip_state_loc_pkey') - ) - - if(alembic_helpers.table_does_not_exist("zip_lookup")): - op.create_table('zip_lookup', - sa.Column('zip', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('st_code', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('state', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('co_code', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('county', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.Column('cs_code', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('cousub', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.Column('pl_code', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('place', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.Column('cnt', sa.INTEGER(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('zip', name='zip_lookup_pkey') - ) - - if(alembic_helpers.table_does_not_exist("county_lookup")): - op.create_table('county_lookup', - sa.Column('st_code', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('state', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('co_code', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('st_code', 'co_code', name='county_lookup_pkey') - ) - op.create_index('county_lookup_state_idx', 'county_lookup', ['state'], unique=False) - op.create_index('county_lookup_name_idx', 'county_lookup', [sa.text('soundex(name::text)')], unique=False) - - if(alembic_helpers.table_does_not_exist("geocode_settings")): - op.create_table('geocode_settings', - sa.Column('name', sa.TEXT(), autoincrement=False, nullable=False), - sa.Column('setting', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('unit', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('category', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('short_desc', sa.TEXT(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('name', name='geocode_settings_pkey') - ) - - if(alembic_helpers.table_does_not_exist("bg")): - op.create_table('bg', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('countyfp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('tractce', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('blkgrpce', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('bg_id', sa.VARCHAR(length=12), autoincrement=False, nullable=False), - sa.Column('namelsad', sa.VARCHAR(length=13), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('funcstat', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('aland', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('awater', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('intptlat', sa.VARCHAR(length=11), autoincrement=False, nullable=True), - sa.Column('intptlon', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(spatial_index=False, from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.CheckConstraint("geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", name='enforce_geotype_geom'), - sa.CheckConstraint('st_ndims(the_geom) = 2', name='enforce_dims_geom'), - sa.CheckConstraint('st_srid(the_geom) = 4269', name='enforce_srid_geom'), - sa.PrimaryKeyConstraint('bg_id', name='bg_pkey'), - comment='block groups' - ) - - if(alembic_helpers.table_does_not_exist("geocode_settings_default")): - op.create_table('geocode_settings_default', - sa.Column('name', sa.TEXT(), autoincrement=False, nullable=False), - sa.Column('setting', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('unit', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('category', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('short_desc', sa.TEXT(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('name', name='geocode_settings_default_pkey') - ) - - if(alembic_helpers.table_does_not_exist("edges")): - op.create_table('edges', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('countyfp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('tlid', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('tfidl', sa.NUMERIC(precision=10, scale=0), autoincrement=False, nullable=True), - sa.Column('tfidr', sa.NUMERIC(precision=10, scale=0), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('fullname', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('smid', sa.VARCHAR(length=22), autoincrement=False, nullable=True), - sa.Column('lfromadd', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('ltoadd', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('rfromadd', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('rtoadd', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('zipl', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('zipr', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('featcat', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('hydroflg', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('railflg', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('roadflg', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('olfflg', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('passflg', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('divroad', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('exttyp', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('ttyp', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('deckedroad', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('artpath', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('persist', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('gcseflg', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('offsetl', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('offsetr', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('tnidf', sa.NUMERIC(precision=10, scale=0), autoincrement=False, nullable=True), - sa.Column('tnidt', sa.NUMERIC(precision=10, scale=0), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.CheckConstraint("geometrytype(the_geom) = 'MULTILINESTRING'::text OR the_geom IS NULL", name='enforce_geotype_the_geom'), - sa.CheckConstraint('st_ndims(the_geom) = 2', name='enforce_dims_the_geom'), - sa.CheckConstraint('st_srid(the_geom) = 4269', name='enforce_srid_the_geom'), - sa.PrimaryKeyConstraint('gid', name='edges_pkey') - ) - op.create_index('idx_tiger_edges_the_geom_gist', 'edges', ['the_geom'], unique=False, postgresql_using='gist') - op.create_index('idx_tiger_edges_countyfp', 'edges', ['countyfp'], unique=False) - op.create_index('idx_edges_tlid', 'edges', ['tlid'], unique=False) - - if(alembic_helpers.table_does_not_exist("faces")): - op.create_table('faces', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('tfid', sa.NUMERIC(precision=10, scale=0), autoincrement=False, nullable=True), - sa.Column('statefp00', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('countyfp00', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('tractce00', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('blkgrpce00', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('blockce00', sa.VARCHAR(length=4), autoincrement=False, nullable=True), - sa.Column('cousubfp00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('submcdfp00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('conctyfp00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('placefp00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('aiannhfp00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('aiannhce00', sa.VARCHAR(length=4), autoincrement=False, nullable=True), - sa.Column('comptyp00', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('trsubfp00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('trsubce00', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('anrcfp00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('elsdlea00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('scsdlea00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('unsdlea00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('uace00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('cd108fp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('sldust00', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('sldlst00', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('vtdst00', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('zcta5ce00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('tazce00', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('ugace00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('puma5ce00', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('countyfp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('tractce', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('blkgrpce', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('blockce', sa.VARCHAR(length=4), autoincrement=False, nullable=True), - sa.Column('cousubfp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('submcdfp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('conctyfp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('placefp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('aiannhfp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('aiannhce', sa.VARCHAR(length=4), autoincrement=False, nullable=True), - sa.Column('comptyp', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('trsubfp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('trsubce', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('anrcfp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('ttractce', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('tblkgpce', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('elsdlea', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('scsdlea', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('unsdlea', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('uace', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('cd111fp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('sldust', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('sldlst', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('vtdst', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('zcta5ce', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('tazce', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('ugace', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('puma5ce', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('csafp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('cbsafp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('metdivfp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('cnectafp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('nectafp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('nctadvfp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('lwflag', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('offset', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('atotal', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('intptlat', sa.VARCHAR(length=11), autoincrement=False, nullable=True), - sa.Column('intptlon', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.Column('tractce20', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('blkgrpce20', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('blockce20', sa.VARCHAR(length=4), autoincrement=False, nullable=True), - sa.Column('countyfp20', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('statefp20', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.CheckConstraint("geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", name='enforce_geotype_the_geom'), - sa.CheckConstraint('st_ndims(the_geom) = 2', name='enforce_dims_the_geom'), - sa.CheckConstraint('st_srid(the_geom) = 4269', name='enforce_srid_the_geom'), - sa.PrimaryKeyConstraint('gid', name='faces_pkey') - ) - op.create_index('tiger_faces_the_geom_gist', 'faces', ['the_geom'], unique=False, postgresql_using='gist') - op.create_index('idx_tiger_faces_tfid', 'faces', ['tfid'], unique=False) - op.create_index('idx_tiger_faces_countyfp', 'faces', ['countyfp'], unique=False) - - if(alembic_helpers.table_does_not_exist("loader_variables")): - op.create_table('loader_variables', - sa.Column('tiger_year', sa.VARCHAR(length=4), autoincrement=False, nullable=False), - sa.Column('website_root', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('staging_fold', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('data_schema', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('staging_schema', sa.TEXT(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('tiger_year', name='loader_variables_pkey') - ) - - if(alembic_helpers.table_does_not_exist("county")): - op.create_table('county', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('countyfp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('countyns', sa.VARCHAR(length=8), autoincrement=False, nullable=True), - sa.Column('cntyidfp', sa.VARCHAR(length=5), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('namelsad', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('lsad', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('classfp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('csafp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('cbsafp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('metdivfp', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('funcstat', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('aland', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('awater', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('intptlat', sa.VARCHAR(length=11), autoincrement=False, nullable=True), - sa.Column('intptlon', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(spatial_index=False, from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.CheckConstraint("geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", name='enforce_geotype_geom'), - sa.CheckConstraint('st_ndims(the_geom) = 2', name='enforce_dims_geom'), - sa.CheckConstraint('st_srid(the_geom) = 4269', name='enforce_srid_geom'), - sa.PrimaryKeyConstraint('cntyidfp', name='pk_tiger_county'), - sa.UniqueConstraint('gid', name='uidx_county_gid') - ) - op.create_index('idx_tiger_county', 'county', ['countyfp'], unique=False) - - if(alembic_helpers.table_does_not_exist("zip_lookup_base")): - op.create_table('zip_lookup_base', - sa.Column('zip', sa.VARCHAR(length=5), autoincrement=False, nullable=False), - sa.Column('state', sa.VARCHAR(length=40), autoincrement=False, nullable=True), - sa.Column('county', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.Column('city', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('zip', name='zip_lookup_base_pkey') - ) - - if(alembic_helpers.table_does_not_exist("tract")): - op.create_table('tract', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('countyfp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('tractce', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('tract_id', sa.VARCHAR(length=11), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=7), autoincrement=False, nullable=True), - sa.Column('namelsad', sa.VARCHAR(length=20), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('funcstat', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('aland', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('awater', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('intptlat', sa.VARCHAR(length=11), autoincrement=False, nullable=True), - sa.Column('intptlon', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(spatial_index=False, from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.CheckConstraint("geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", name='enforce_geotype_geom'), - sa.CheckConstraint('st_ndims(the_geom) = 2', name='enforce_dims_geom'), - sa.CheckConstraint('st_srid(the_geom) = 4269', name='enforce_srid_geom'), - sa.PrimaryKeyConstraint('tract_id', name='tract_pkey') - ) - - if(alembic_helpers.table_does_not_exist("layer")): - 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='layer_topology_id_fkey'), - sa.PrimaryKeyConstraint('topology_id', 'layer_id', name='layer_pkey'), - sa.UniqueConstraint('schema_name', 'table_name', 'feature_column', name='layer_schema_name_table_name_feature_column_key') - ) - - if(alembic_helpers.table_does_not_exist("street_type_lookup")): - op.create_table('street_type_lookup', - sa.Column('name', sa.VARCHAR(length=50), autoincrement=False, nullable=False), - sa.Column('abbrev', sa.VARCHAR(length=50), autoincrement=False, nullable=True), - sa.Column('is_hw', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False), - sa.PrimaryKeyConstraint('name', name='street_type_lookup_pkey') - ) - op.create_index('street_type_lookup_abbrev_idx', 'street_type_lookup', ['abbrev'], unique=False) - - if(alembic_helpers.table_does_not_exist("taskpolygons")): - op.create_table('taskpolygons', - sa.Column('geom', geoalchemy2.types.Geometry(from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.Column('clusteruid', sa.TEXT(), autoincrement=False, nullable=True) - ) - op.create_index('taskpolygons_idx', 'taskpolygons', ['geom'], unique=False, postgresql_using='gist') - - if(alembic_helpers.table_does_not_exist("tabblock")): - op.create_table('tabblock', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('countyfp', sa.VARCHAR(length=3), autoincrement=False, nullable=True), - sa.Column('tractce', sa.VARCHAR(length=6), autoincrement=False, nullable=True), - sa.Column('blockce', sa.VARCHAR(length=4), autoincrement=False, nullable=True), - sa.Column('tabblock_id', sa.VARCHAR(length=16), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=20), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('ur', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('uace', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('funcstat', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('aland', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('awater', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True), - sa.Column('intptlat', sa.VARCHAR(length=11), autoincrement=False, nullable=True), - sa.Column('intptlon', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(spatial_index=False, from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.CheckConstraint("geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", name='enforce_geotype_geom'), - sa.CheckConstraint('st_ndims(the_geom) = 2', name='enforce_dims_geom'), - sa.CheckConstraint('st_srid(the_geom) = 4269', name='enforce_srid_geom'), - sa.PrimaryKeyConstraint('tabblock_id', name='tabblock_pkey') - ) - - if(alembic_helpers.table_does_not_exist("countysub_lookup")): - op.create_table('countysub_lookup', - sa.Column('st_code', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('state', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('co_code', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('county', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.Column('cs_code', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=90), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('st_code', 'co_code', 'cs_code', name='countysub_lookup_pkey') - ) - op.create_index('countysub_lookup_state_idx', 'countysub_lookup', ['state'], unique=False) - op.create_index('countysub_lookup_name_idx', 'countysub_lookup', [sa.text('soundex(name::text)')], unique=False) - - if(alembic_helpers.table_does_not_exist("addr")): - op.create_table('addr', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('tlid', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('fromhn', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('tohn', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('side', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('zip', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('plus4', sa.VARCHAR(length=4), autoincrement=False, nullable=True), - sa.Column('fromtyp', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('totyp', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('fromarmid', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('toarmid', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('arid', sa.VARCHAR(length=22), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('gid', name='addr_pkey') - ) - op.create_index('idx_tiger_addr_zip', 'addr', ['zip'], unique=False) - op.create_index('idx_tiger_addr_tlid_statefp', 'addr', ['tlid', 'statefp'], unique=False) - - if(alembic_helpers.table_does_not_exist("voronois")): - op.create_table('voronois', - sa.Column('clusteruid', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('geom', geoalchemy2.types.Geometry(from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True) - ) - op.create_index('voronois_idx', 'voronois', ['geom'], unique=False, postgresql_using='gist') - - if(alembic_helpers.table_does_not_exist("state")): - op.create_table('state', - sa.Column('gid', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('region', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('division', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('statefp', sa.VARCHAR(length=2), autoincrement=False, nullable=False), - sa.Column('statens', sa.VARCHAR(length=8), autoincrement=False, nullable=True), - sa.Column('stusps', sa.VARCHAR(length=2), autoincrement=False, nullable=False), - sa.Column('name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('lsad', sa.VARCHAR(length=2), autoincrement=False, nullable=True), - sa.Column('mtfcc', sa.VARCHAR(length=5), autoincrement=False, nullable=True), - sa.Column('funcstat', sa.VARCHAR(length=1), autoincrement=False, nullable=True), - sa.Column('aland', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('awater', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('intptlat', sa.VARCHAR(length=11), autoincrement=False, nullable=True), - sa.Column('intptlon', sa.VARCHAR(length=12), autoincrement=False, nullable=True), - sa.Column('the_geom', geoalchemy2.types.Geometry(from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.CheckConstraint("geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", name='enforce_geotype_the_geom'), - sa.CheckConstraint('st_ndims(the_geom) = 2', name='enforce_dims_the_geom'), - sa.CheckConstraint('st_srid(the_geom) = 4269', name='enforce_srid_the_geom'), - sa.PrimaryKeyConstraint('statefp', name='pk_tiger_state'), - sa.UniqueConstraint('gid', name='uidx_tiger_state_gid'), - sa.UniqueConstraint('stusps', name='uidx_tiger_state_stusps') - ) - op.create_index('idx_tiger_state_the_geom_gist', 'state', ['the_geom'], unique=False, postgresql_using='gist') - - if(alembic_helpers.table_does_not_exist("clusteredbuildings")): - op.create_table('clusteredbuildings', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('project_id', sa.VARCHAR(), autoincrement=False, nullable=True), - sa.Column('osm_id', sa.VARCHAR(), autoincrement=False, nullable=True), - sa.Column('geom', geoalchemy2.types.Geometry(geometry_type='POLYGON', srid=4326, from_text='ST_GeomFromEWKT', name='geometry', _spatial_index_reflected=True), autoincrement=False, nullable=True), - sa.Column('tags', postgresql.JSONB(astext_type=sa.Text()), autoincrement=False, nullable=True), - sa.Column('polyid', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('numfeatures', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('cid', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('clusteruid', sa.TEXT(), autoincrement=False, nullable=True) - ) - op.create_index('clusteredbuildings_idx', 'clusteredbuildings', ['geom'], unique=False, postgresql_using='gist') - - if(alembic_helpers.table_does_not_exist("loader_lookuptables")): - op.create_table('loader_lookuptables', - sa.Column('process_order', sa.INTEGER(), server_default=sa.text('1000'), autoincrement=False, nullable=False), - sa.Column('lookup_name', sa.TEXT(), autoincrement=False, nullable=False, comment='This is the table name to inherit from and suffix of resulting output table -- how the table will be named -- edges here would mean -- ma_edges , pa_edges etc. except in the case of national tables. national level tables have no prefix'), - sa.Column('table_name', sa.TEXT(), autoincrement=False, nullable=True, comment='suffix of the tables to load e.g. edges would load all tables like *edges.dbf(shp) -- so tl_2010_42129_edges.dbf . '), - sa.Column('single_mode', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False), - sa.Column('load', sa.BOOLEAN(), server_default=sa.text('true'), autoincrement=False, nullable=False, comment="Whether or not to load the table. For states and zcta5 (you may just want to download states10, zcta510 nationwide file manually) load your own into a single table that inherits from tiger.states, tiger.zcta5. You'll get improved performance for some geocoding cases."), - sa.Column('level_county', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False), - sa.Column('level_state', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False), - sa.Column('level_nation', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False, comment='These are tables that contain all data for the whole US so there is just a single file'), - sa.Column('post_load_process', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('single_geom_mode', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True), - sa.Column('insert_mode', sa.CHAR(length=1), server_default=sa.text("'c'::bpchar"), autoincrement=False, nullable=False), - sa.Column('pre_load_process', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('columns_exclude', postgresql.ARRAY(sa.TEXT()), autoincrement=False, nullable=True, comment='List of columns to exclude as an array. This is excluded from both input table and output table and rest of columns remaining are assumed to be in same order in both tables. gid, geoid,cpi,suffix1ce are excluded if no columns are specified.'), - sa.Column('website_root_override', sa.TEXT(), autoincrement=False, nullable=True, comment='Path to use for wget instead of that specified in year table. Needed currently for zcta where they release that only for 2000 and 2010'), - sa.PrimaryKeyConstraint('lookup_name', name='loader_lookuptables_pkey') + if alembic_helpers.table_does_not_exist("loader_platform"): + op.create_table( + "loader_platform", + sa.Column("os", sa.VARCHAR(length=50), autoincrement=False, nullable=False), + sa.Column("declare_sect", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("pgbin", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("wget", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("unzip_command", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("psql", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("path_sep", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("loader", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column( + "environ_set_command", sa.TEXT(), autoincrement=False, nullable=True + ), + sa.Column( + "county_process_command", sa.TEXT(), autoincrement=False, nullable=True + ), + sa.PrimaryKeyConstraint("os", name="loader_platform_pkey"), + ) + + if alembic_helpers.table_does_not_exist("dumpedpoints"): + op.create_table( + "dumpedpoints", + sa.Column("osm_id", sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column("polyid", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column("cid", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column("clusteruid", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column( + "geom", + geoalchemy2.types.Geometry( + geometry_type="POINT", + srid=4326, + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + ) + op.create_index( + "dumpedpoints_idx", + "dumpedpoints", + ["geom"], + unique=False, + postgresql_using="gist", + ) + + if alembic_helpers.table_does_not_exist("pagc_lex"): + op.create_table( + "pagc_lex", + sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column("seq", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column("word", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("stdword", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("token", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "is_custom", + sa.BOOLEAN(), + server_default=sa.text("true"), + autoincrement=False, + nullable=False, + ), + sa.PrimaryKeyConstraint("id", name="pagc_lex_pkey"), + ) + + if alembic_helpers.table_does_not_exist("zip_lookup_all"): + op.create_table( + "zip_lookup_all", + sa.Column("zip", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column("st_code", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "state", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column("co_code", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "county", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.Column("cs_code", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "cousub", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.Column("pl_code", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "place", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.Column("cnt", sa.INTEGER(), autoincrement=False, nullable=True), + ) + + if alembic_helpers.table_does_not_exist("pagc_rules"): + op.create_table( + "pagc_rules", + sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column("rule", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column( + "is_custom", + sa.BOOLEAN(), + server_default=sa.text("true"), + autoincrement=False, + nullable=True, + ), + sa.PrimaryKeyConstraint("id", name="pagc_rules_pkey"), + ) + + if alembic_helpers.table_does_not_exist("addrfeat"): + op.create_table( + "addrfeat", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column("tlid", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=False + ), + sa.Column( + "aridl", sa.VARCHAR(length=22), autoincrement=False, nullable=True + ), + sa.Column( + "aridr", sa.VARCHAR(length=22), autoincrement=False, nullable=True + ), + sa.Column( + "linearid", sa.VARCHAR(length=22), autoincrement=False, nullable=True + ), + sa.Column( + "fullname", sa.VARCHAR(length=100), autoincrement=False, nullable=True + ), + sa.Column( + "lfromhn", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "ltohn", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "rfromhn", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "rtohn", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column("zipl", sa.VARCHAR(length=5), autoincrement=False, nullable=True), + sa.Column("zipr", sa.VARCHAR(length=5), autoincrement=False, nullable=True), + sa.Column( + "edge_mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "parityl", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "parityr", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "plus4l", sa.VARCHAR(length=4), autoincrement=False, nullable=True + ), + sa.Column( + "plus4r", sa.VARCHAR(length=4), autoincrement=False, nullable=True + ), + sa.Column( + "lfromtyp", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "ltotyp", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "rfromtyp", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "rtotyp", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "offsetl", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "offsetr", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.CheckConstraint( + "geometrytype(the_geom) = 'LINESTRING'::text OR the_geom IS NULL", + name="enforce_geotype_the_geom", + ), + sa.CheckConstraint("st_ndims(the_geom) = 2", name="enforce_dims_the_geom"), + sa.CheckConstraint( + "st_srid(the_geom) = 4269", name="enforce_srid_the_geom" + ), + sa.PrimaryKeyConstraint("gid", name="addrfeat_pkey"), + ) + op.create_index("idx_addrfeat_zipr", "addrfeat", ["zipr"], unique=False) + op.create_index("idx_addrfeat_zipl", "addrfeat", ["zipl"], unique=False) + op.create_index("idx_addrfeat_tlid", "addrfeat", ["tlid"], unique=False) + op.create_index( + "idx_addrfeat_geom_gist", + "addrfeat", + ["the_geom"], + unique=False, + postgresql_using="gist", + ) + + if alembic_helpers.table_does_not_exist("topology"): + op.create_table( + "topology", + sa.Column( + "id", + sa.INTEGER(), + server_default=sa.text("nextval('topology_id_seq'::regclass)"), + 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.PrimaryKeyConstraint("id", name="topology_pkey"), + sa.UniqueConstraint("name", name="topology_name_key"), + postgresql_ignore_search_path=False, + ) + + if alembic_helpers.table_does_not_exist("featnames"): + op.create_table( + "featnames", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column("tlid", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column( + "fullname", sa.VARCHAR(length=100), autoincrement=False, nullable=True + ), + sa.Column( + "name", sa.VARCHAR(length=100), autoincrement=False, nullable=True + ), + sa.Column( + "predirabrv", sa.VARCHAR(length=15), autoincrement=False, nullable=True + ), + sa.Column( + "pretypabrv", sa.VARCHAR(length=50), autoincrement=False, nullable=True + ), + sa.Column( + "prequalabr", sa.VARCHAR(length=15), autoincrement=False, nullable=True + ), + sa.Column( + "sufdirabrv", sa.VARCHAR(length=15), autoincrement=False, nullable=True + ), + sa.Column( + "suftypabrv", sa.VARCHAR(length=50), autoincrement=False, nullable=True + ), + sa.Column( + "sufqualabr", sa.VARCHAR(length=15), autoincrement=False, nullable=True + ), + sa.Column( + "predir", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "pretyp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "prequal", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "sufdir", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "suftyp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "sufqual", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "linearid", sa.VARCHAR(length=22), autoincrement=False, nullable=True + ), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "paflag", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.PrimaryKeyConstraint("gid", name="featnames_pkey"), + ) + op.create_index( + "idx_tiger_featnames_tlid_statefp", + "featnames", + ["tlid", "statefp"], + unique=False, + ) + op.create_index( + "idx_tiger_featnames_snd_name", + "featnames", + [sa.text("soundex(name::text)")], + unique=False, + ) + op.create_index( + "idx_tiger_featnames_lname", + "featnames", + [sa.text("lower(name::text)")], + unique=False, + ) + + if alembic_helpers.table_does_not_exist("buildings"): + op.create_table( + "buildings", + sa.Column("id", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column("project_id", sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column("osm_id", sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column( + "geom", + geoalchemy2.types.Geometry( + geometry_type="POLYGON", + srid=4326, + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.Column( + "tags", + postgresql.JSONB(astext_type=sa.Text()), + autoincrement=False, + nullable=True, + ), + sa.Column("polyid", sa.BIGINT(), autoincrement=False, nullable=True), + ) + op.create_index( + "buildings_idx", + "buildings", + ["geom"], + unique=False, + postgresql_using="gist", + ) + + if alembic_helpers.table_does_not_exist("zcta5"): + op.create_table( + "zcta5", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=False + ), + sa.Column( + "zcta5ce", sa.VARCHAR(length=5), autoincrement=False, nullable=False + ), + sa.Column( + "classfp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "funcstat", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "aland", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "awater", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "intptlat", sa.VARCHAR(length=11), autoincrement=False, nullable=True + ), + sa.Column( + "intptlon", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "partflg", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + spatial_index=False, + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.CheckConstraint( + "geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", + name="enforce_geotype_the_geom", + ), + sa.CheckConstraint("st_ndims(the_geom) = 2", name="enforce_dims_the_geom"), + sa.CheckConstraint( + "st_srid(the_geom) = 4269", name="enforce_srid_the_geom" + ), + sa.PrimaryKeyConstraint( + "zcta5ce", "statefp", name="pk_tiger_zcta5_zcta5ce" + ), + sa.UniqueConstraint("gid", name="uidx_tiger_zcta5_gid"), + ) + + if alembic_helpers.table_does_not_exist("secondary_unit_lookup"): + op.create_table( + "secondary_unit_lookup", + sa.Column( + "name", sa.VARCHAR(length=20), autoincrement=False, nullable=False + ), + sa.Column( + "abbrev", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.PrimaryKeyConstraint("name", name="secondary_unit_lookup_pkey"), + ) + op.create_index( + "secondary_unit_lookup_abbrev_idx", + "secondary_unit_lookup", + ["abbrev"], + unique=False, + ) + + if alembic_helpers.table_does_not_exist("pagc_gaz"): + op.create_table( + "pagc_gaz", + sa.Column("id", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column("seq", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column("word", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("stdword", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("token", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "is_custom", + sa.BOOLEAN(), + server_default=sa.text("true"), + autoincrement=False, + nullable=False, + ), + sa.PrimaryKeyConstraint("id", name="pagc_gaz_pkey"), + ) + + if alembic_helpers.table_does_not_exist("direction_lookup"): + op.create_table( + "direction_lookup", + sa.Column( + "name", sa.VARCHAR(length=20), autoincrement=False, nullable=False + ), + sa.Column( + "abbrev", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.PrimaryKeyConstraint("name", name="direction_lookup_pkey"), + ) + op.create_index( + "direction_lookup_abbrev_idx", "direction_lookup", ["abbrev"], unique=False + ) + + if alembic_helpers.table_does_not_exist("state_lookup"): + op.create_table( + "state_lookup", + sa.Column("st_code", sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column( + "name", sa.VARCHAR(length=40), autoincrement=False, nullable=True + ), + sa.Column( + "abbrev", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column("statefp", sa.CHAR(length=2), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint("st_code", name="state_lookup_pkey"), + sa.UniqueConstraint("abbrev", name="state_lookup_abbrev_key"), + sa.UniqueConstraint("name", name="state_lookup_name_key"), + sa.UniqueConstraint("statefp", name="state_lookup_statefp_key"), + ) + + if alembic_helpers.table_does_not_exist("tabblock20"): + op.create_table( + "tabblock20", + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "countyfp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "tractce", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "blockce", sa.VARCHAR(length=4), autoincrement=False, nullable=True + ), + sa.Column( + "geoid", sa.VARCHAR(length=15), autoincrement=False, nullable=False + ), + sa.Column( + "name", sa.VARCHAR(length=10), autoincrement=False, nullable=True + ), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column("ur", sa.VARCHAR(length=1), autoincrement=False, nullable=True), + sa.Column("uace", sa.VARCHAR(length=5), autoincrement=False, nullable=True), + sa.Column( + "uatype", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "funcstat", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "aland", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "awater", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "intptlat", sa.VARCHAR(length=11), autoincrement=False, nullable=True + ), + sa.Column( + "intptlon", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + geometry_type="MULTIPOLYGON", + srid=4269, + spatial_index=False, + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.Column( + "housing", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "pop", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.PrimaryKeyConstraint("geoid", name="pk_tabblock20"), + ) + + if alembic_helpers.table_does_not_exist("splitpolygons"): + op.create_table( + "splitpolygons", + sa.Column("polyid", sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column( + "geom", + geoalchemy2.types.Geometry( + geometry_type="POLYGON", + srid=4326, + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.Column( + "geog", + geoalchemy2.types.Geography( + from_text="ST_GeogFromText", name="geography" + ), + autoincrement=False, + nullable=True, + ), + sa.Column("numfeatures", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column( + "area", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.PrimaryKeyConstraint("polyid", name="splitpolygons_pkey"), + ) + op.create_index( + "splitpolygons_idx", + "splitpolygons", + ["geom"], + unique=False, + postgresql_using="gist", + ) + + if alembic_helpers.table_does_not_exist("cousub"): + op.create_table( + "cousub", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "countyfp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "cousubfp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "cousubns", sa.VARCHAR(length=8), autoincrement=False, nullable=True + ), + sa.Column( + "cosbidfp", sa.VARCHAR(length=10), autoincrement=False, nullable=False + ), + sa.Column( + "name", sa.VARCHAR(length=100), autoincrement=False, nullable=True + ), + sa.Column( + "namelsad", sa.VARCHAR(length=100), autoincrement=False, nullable=True + ), + sa.Column("lsad", sa.VARCHAR(length=2), autoincrement=False, nullable=True), + sa.Column( + "classfp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "cnectafp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "nectafp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "nctadvfp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "funcstat", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "aland", + sa.NUMERIC(precision=14, scale=0), + autoincrement=False, + nullable=True, + ), + sa.Column( + "awater", + sa.NUMERIC(precision=14, scale=0), + autoincrement=False, + nullable=True, + ), + sa.Column( + "intptlat", sa.VARCHAR(length=11), autoincrement=False, nullable=True + ), + sa.Column( + "intptlon", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.CheckConstraint( + "geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", + name="enforce_geotype_the_geom", + ), + sa.CheckConstraint("st_ndims(the_geom) = 2", name="enforce_dims_the_geom"), + sa.CheckConstraint( + "st_srid(the_geom) = 4269", name="enforce_srid_the_geom" + ), + sa.PrimaryKeyConstraint("cosbidfp", name="cousub_pkey"), + sa.UniqueConstraint("gid", name="uidx_cousub_gid"), + ) + op.create_index( + "tige_cousub_the_geom_gist", + "cousub", + ["the_geom"], + unique=False, + postgresql_using="gist", + ) + + if alembic_helpers.table_does_not_exist("zip_state"): + op.create_table( + "zip_state", + sa.Column("zip", sa.VARCHAR(length=5), autoincrement=False, nullable=False), + sa.Column( + "stusps", sa.VARCHAR(length=2), autoincrement=False, nullable=False + ), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.PrimaryKeyConstraint("zip", "stusps", name="zip_state_pkey"), + ) + + if alembic_helpers.table_does_not_exist("place_lookup"): + op.create_table( + "place_lookup", + sa.Column("st_code", sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column( + "state", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column("pl_code", sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column( + "name", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.PrimaryKeyConstraint("st_code", "pl_code", name="place_lookup_pkey"), + ) + op.create_index( + "place_lookup_state_idx", "place_lookup", ["state"], unique=False + ) + op.create_index( + "place_lookup_name_idx", + "place_lookup", + [sa.text("soundex(name::text)")], + unique=False, + ) + + if alembic_helpers.table_does_not_exist("lowfeaturecountpolygons"): + op.create_table( + "lowfeaturecountpolygons", + sa.Column("polyid", sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column( + "geom", + geoalchemy2.types.Geometry( + geometry_type="POLYGON", + srid=4326, + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.Column( + "geog", + geoalchemy2.types.Geography( + from_text="ST_GeogFromText", name="geography" + ), + autoincrement=False, + nullable=True, + ), + sa.Column("numfeatures", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column( + "area", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column("n_polyid", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column( + "n_area", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column("n_numfeatures", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column( + "sharedbound", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.PrimaryKeyConstraint("polyid", name="lowfeaturecountpolygons_pkey"), + ) + op.create_index( + "lowfeaturecountpolygons_idx", + "lowfeaturecountpolygons", + ["geom"], + unique=False, + postgresql_using="gist", + ) + + if alembic_helpers.table_does_not_exist("place"): + op.create_table( + "place", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "placefp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "placens", sa.VARCHAR(length=8), autoincrement=False, nullable=True + ), + sa.Column( + "plcidfp", sa.VARCHAR(length=7), autoincrement=False, nullable=False + ), + sa.Column( + "name", sa.VARCHAR(length=100), autoincrement=False, nullable=True + ), + sa.Column( + "namelsad", sa.VARCHAR(length=100), autoincrement=False, nullable=True + ), + sa.Column("lsad", sa.VARCHAR(length=2), autoincrement=False, nullable=True), + sa.Column( + "classfp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column("cpi", sa.VARCHAR(length=1), autoincrement=False, nullable=True), + sa.Column( + "pcicbsa", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "pcinecta", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "funcstat", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column("aland", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column("awater", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column( + "intptlat", sa.VARCHAR(length=11), autoincrement=False, nullable=True + ), + sa.Column( + "intptlon", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.CheckConstraint( + "geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", + name="enforce_geotype_the_geom", + ), + sa.CheckConstraint("st_ndims(the_geom) = 2", name="enforce_dims_the_geom"), + sa.CheckConstraint( + "st_srid(the_geom) = 4269", name="enforce_srid_the_geom" + ), + sa.PrimaryKeyConstraint("plcidfp", name="place_pkey"), + sa.UniqueConstraint("gid", name="uidx_tiger_place_gid"), + ) + op.create_index( + "tiger_place_the_geom_gist", + "place", + ["the_geom"], + unique=False, + postgresql_using="gist", + ) + + if alembic_helpers.table_does_not_exist("zip_state_loc"): + op.create_table( + "zip_state_loc", + sa.Column("zip", sa.VARCHAR(length=5), autoincrement=False, nullable=False), + sa.Column( + "stusps", sa.VARCHAR(length=2), autoincrement=False, nullable=False + ), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "place", sa.VARCHAR(length=100), autoincrement=False, nullable=False + ), + sa.PrimaryKeyConstraint( + "zip", "stusps", "place", name="zip_state_loc_pkey" + ), + ) + + if alembic_helpers.table_does_not_exist("zip_lookup"): + op.create_table( + "zip_lookup", + sa.Column("zip", sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column("st_code", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "state", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column("co_code", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "county", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.Column("cs_code", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "cousub", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.Column("pl_code", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "place", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.Column("cnt", sa.INTEGER(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint("zip", name="zip_lookup_pkey"), + ) + + if alembic_helpers.table_does_not_exist("county_lookup"): + op.create_table( + "county_lookup", + sa.Column("st_code", sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column( + "state", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column("co_code", sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column( + "name", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.PrimaryKeyConstraint("st_code", "co_code", name="county_lookup_pkey"), + ) + op.create_index( + "county_lookup_state_idx", "county_lookup", ["state"], unique=False + ) + op.create_index( + "county_lookup_name_idx", + "county_lookup", + [sa.text("soundex(name::text)")], + unique=False, + ) + + if alembic_helpers.table_does_not_exist("geocode_settings"): + op.create_table( + "geocode_settings", + sa.Column("name", sa.TEXT(), autoincrement=False, nullable=False), + sa.Column("setting", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("unit", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("category", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("short_desc", sa.TEXT(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint("name", name="geocode_settings_pkey"), + ) + + if alembic_helpers.table_does_not_exist("bg"): + op.create_table( + "bg", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "countyfp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "tractce", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "blkgrpce", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "bg_id", sa.VARCHAR(length=12), autoincrement=False, nullable=False + ), + sa.Column( + "namelsad", sa.VARCHAR(length=13), autoincrement=False, nullable=True + ), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "funcstat", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "aland", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "awater", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "intptlat", sa.VARCHAR(length=11), autoincrement=False, nullable=True + ), + sa.Column( + "intptlon", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + spatial_index=False, + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.CheckConstraint( + "geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", + name="enforce_geotype_geom", + ), + sa.CheckConstraint("st_ndims(the_geom) = 2", name="enforce_dims_geom"), + sa.CheckConstraint("st_srid(the_geom) = 4269", name="enforce_srid_geom"), + sa.PrimaryKeyConstraint("bg_id", name="bg_pkey"), + comment="block groups", + ) + + if alembic_helpers.table_does_not_exist("geocode_settings_default"): + op.create_table( + "geocode_settings_default", + sa.Column("name", sa.TEXT(), autoincrement=False, nullable=False), + sa.Column("setting", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("unit", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("category", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("short_desc", sa.TEXT(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint("name", name="geocode_settings_default_pkey"), + ) + + if alembic_helpers.table_does_not_exist("edges"): + op.create_table( + "edges", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "countyfp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column("tlid", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column( + "tfidl", + sa.NUMERIC(precision=10, scale=0), + autoincrement=False, + nullable=True, + ), + sa.Column( + "tfidr", + sa.NUMERIC(precision=10, scale=0), + autoincrement=False, + nullable=True, + ), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "fullname", sa.VARCHAR(length=100), autoincrement=False, nullable=True + ), + sa.Column( + "smid", sa.VARCHAR(length=22), autoincrement=False, nullable=True + ), + sa.Column( + "lfromadd", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "ltoadd", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "rfromadd", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "rtoadd", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column("zipl", sa.VARCHAR(length=5), autoincrement=False, nullable=True), + sa.Column("zipr", sa.VARCHAR(length=5), autoincrement=False, nullable=True), + sa.Column( + "featcat", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "hydroflg", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "railflg", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "roadflg", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "olfflg", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "passflg", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "divroad", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "exttyp", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column("ttyp", sa.VARCHAR(length=1), autoincrement=False, nullable=True), + sa.Column( + "deckedroad", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "artpath", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "persist", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "gcseflg", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "offsetl", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "offsetr", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "tnidf", + sa.NUMERIC(precision=10, scale=0), + autoincrement=False, + nullable=True, + ), + sa.Column( + "tnidt", + sa.NUMERIC(precision=10, scale=0), + autoincrement=False, + nullable=True, + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.CheckConstraint( + "geometrytype(the_geom) = 'MULTILINESTRING'::text OR the_geom IS NULL", + name="enforce_geotype_the_geom", + ), + sa.CheckConstraint("st_ndims(the_geom) = 2", name="enforce_dims_the_geom"), + sa.CheckConstraint( + "st_srid(the_geom) = 4269", name="enforce_srid_the_geom" + ), + sa.PrimaryKeyConstraint("gid", name="edges_pkey"), + ) + op.create_index( + "idx_tiger_edges_the_geom_gist", + "edges", + ["the_geom"], + unique=False, + postgresql_using="gist", + ) + op.create_index("idx_tiger_edges_countyfp", "edges", ["countyfp"], unique=False) + op.create_index("idx_edges_tlid", "edges", ["tlid"], unique=False) + + if alembic_helpers.table_does_not_exist("faces"): + op.create_table( + "faces", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column( + "tfid", + sa.NUMERIC(precision=10, scale=0), + autoincrement=False, + nullable=True, + ), + sa.Column( + "statefp00", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "countyfp00", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "tractce00", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "blkgrpce00", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "blockce00", sa.VARCHAR(length=4), autoincrement=False, nullable=True + ), + sa.Column( + "cousubfp00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "submcdfp00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "conctyfp00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "placefp00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "aiannhfp00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "aiannhce00", sa.VARCHAR(length=4), autoincrement=False, nullable=True + ), + sa.Column( + "comptyp00", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "trsubfp00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "trsubce00", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "anrcfp00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "elsdlea00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "scsdlea00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "unsdlea00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "uace00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "cd108fp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "sldust00", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "sldlst00", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "vtdst00", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "zcta5ce00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "tazce00", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "ugace00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "puma5ce00", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "countyfp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "tractce", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "blkgrpce", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "blockce", sa.VARCHAR(length=4), autoincrement=False, nullable=True + ), + sa.Column( + "cousubfp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "submcdfp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "conctyfp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "placefp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "aiannhfp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "aiannhce", sa.VARCHAR(length=4), autoincrement=False, nullable=True + ), + sa.Column( + "comptyp", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "trsubfp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "trsubce", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "anrcfp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "ttractce", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "tblkgpce", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "elsdlea", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "scsdlea", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "unsdlea", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column("uace", sa.VARCHAR(length=5), autoincrement=False, nullable=True), + sa.Column( + "cd111fp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "sldust", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "sldlst", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "vtdst", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "zcta5ce", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "tazce", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "ugace", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "puma5ce", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "csafp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "cbsafp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "metdivfp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "cnectafp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "nectafp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "nctadvfp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "lwflag", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "offset", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "atotal", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "intptlat", sa.VARCHAR(length=11), autoincrement=False, nullable=True + ), + sa.Column( + "intptlon", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.Column( + "tractce20", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "blkgrpce20", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "blockce20", sa.VARCHAR(length=4), autoincrement=False, nullable=True + ), + sa.Column( + "countyfp20", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "statefp20", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.CheckConstraint( + "geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", + name="enforce_geotype_the_geom", + ), + sa.CheckConstraint("st_ndims(the_geom) = 2", name="enforce_dims_the_geom"), + sa.CheckConstraint( + "st_srid(the_geom) = 4269", name="enforce_srid_the_geom" + ), + sa.PrimaryKeyConstraint("gid", name="faces_pkey"), + ) + op.create_index( + "tiger_faces_the_geom_gist", + "faces", + ["the_geom"], + unique=False, + postgresql_using="gist", + ) + op.create_index("idx_tiger_faces_tfid", "faces", ["tfid"], unique=False) + op.create_index("idx_tiger_faces_countyfp", "faces", ["countyfp"], unique=False) + + if alembic_helpers.table_does_not_exist("loader_variables"): + op.create_table( + "loader_variables", + sa.Column( + "tiger_year", sa.VARCHAR(length=4), autoincrement=False, nullable=False + ), + sa.Column("website_root", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("staging_fold", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("data_schema", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column("staging_schema", sa.TEXT(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint("tiger_year", name="loader_variables_pkey"), + ) + + if alembic_helpers.table_does_not_exist("county"): + op.create_table( + "county", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "countyfp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "countyns", sa.VARCHAR(length=8), autoincrement=False, nullable=True + ), + sa.Column( + "cntyidfp", sa.VARCHAR(length=5), autoincrement=False, nullable=False + ), + sa.Column( + "name", sa.VARCHAR(length=100), autoincrement=False, nullable=True + ), + sa.Column( + "namelsad", sa.VARCHAR(length=100), autoincrement=False, nullable=True + ), + sa.Column("lsad", sa.VARCHAR(length=2), autoincrement=False, nullable=True), + sa.Column( + "classfp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "csafp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "cbsafp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "metdivfp", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "funcstat", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column("aland", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column( + "awater", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "intptlat", sa.VARCHAR(length=11), autoincrement=False, nullable=True + ), + sa.Column( + "intptlon", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + spatial_index=False, + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.CheckConstraint( + "geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", + name="enforce_geotype_geom", + ), + sa.CheckConstraint("st_ndims(the_geom) = 2", name="enforce_dims_geom"), + sa.CheckConstraint("st_srid(the_geom) = 4269", name="enforce_srid_geom"), + sa.PrimaryKeyConstraint("cntyidfp", name="pk_tiger_county"), + sa.UniqueConstraint("gid", name="uidx_county_gid"), + ) + op.create_index("idx_tiger_county", "county", ["countyfp"], unique=False) + + if alembic_helpers.table_does_not_exist("zip_lookup_base"): + op.create_table( + "zip_lookup_base", + sa.Column("zip", sa.VARCHAR(length=5), autoincrement=False, nullable=False), + sa.Column( + "state", sa.VARCHAR(length=40), autoincrement=False, nullable=True + ), + sa.Column( + "county", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.Column( + "city", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.PrimaryKeyConstraint("zip", name="zip_lookup_base_pkey"), + ) + + if alembic_helpers.table_does_not_exist("tract"): + op.create_table( + "tract", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "countyfp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "tractce", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "tract_id", sa.VARCHAR(length=11), autoincrement=False, nullable=False + ), + sa.Column("name", sa.VARCHAR(length=7), autoincrement=False, nullable=True), + sa.Column( + "namelsad", sa.VARCHAR(length=20), autoincrement=False, nullable=True + ), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "funcstat", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "aland", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "awater", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "intptlat", sa.VARCHAR(length=11), autoincrement=False, nullable=True + ), + sa.Column( + "intptlon", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + spatial_index=False, + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.CheckConstraint( + "geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", + name="enforce_geotype_geom", + ), + sa.CheckConstraint("st_ndims(the_geom) = 2", name="enforce_dims_geom"), + sa.CheckConstraint("st_srid(the_geom) = 4269", name="enforce_srid_geom"), + sa.PrimaryKeyConstraint("tract_id", name="tract_pkey"), + ) + + if alembic_helpers.table_does_not_exist("layer"): + 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="layer_topology_id_fkey" + ), + sa.PrimaryKeyConstraint("topology_id", "layer_id", name="layer_pkey"), + sa.UniqueConstraint( + "schema_name", + "table_name", + "feature_column", + name="layer_schema_name_table_name_feature_column_key", + ), + ) + + if alembic_helpers.table_does_not_exist("street_type_lookup"): + op.create_table( + "street_type_lookup", + sa.Column( + "name", sa.VARCHAR(length=50), autoincrement=False, nullable=False + ), + sa.Column( + "abbrev", sa.VARCHAR(length=50), autoincrement=False, nullable=True + ), + sa.Column( + "is_hw", + sa.BOOLEAN(), + server_default=sa.text("false"), + autoincrement=False, + nullable=False, + ), + sa.PrimaryKeyConstraint("name", name="street_type_lookup_pkey"), + ) + op.create_index( + "street_type_lookup_abbrev_idx", + "street_type_lookup", + ["abbrev"], + unique=False, + ) + + if alembic_helpers.table_does_not_exist("taskpolygons"): + op.create_table( + "taskpolygons", + sa.Column( + "geom", + geoalchemy2.types.Geometry( + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.Column("clusteruid", sa.TEXT(), autoincrement=False, nullable=True), + ) + op.create_index( + "taskpolygons_idx", + "taskpolygons", + ["geom"], + unique=False, + postgresql_using="gist", + ) + + if alembic_helpers.table_does_not_exist("tabblock"): + op.create_table( + "tabblock", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "countyfp", sa.VARCHAR(length=3), autoincrement=False, nullable=True + ), + sa.Column( + "tractce", sa.VARCHAR(length=6), autoincrement=False, nullable=True + ), + sa.Column( + "blockce", sa.VARCHAR(length=4), autoincrement=False, nullable=True + ), + sa.Column( + "tabblock_id", + sa.VARCHAR(length=16), + autoincrement=False, + nullable=False, + ), + sa.Column( + "name", sa.VARCHAR(length=20), autoincrement=False, nullable=True + ), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column("ur", sa.VARCHAR(length=1), autoincrement=False, nullable=True), + sa.Column("uace", sa.VARCHAR(length=5), autoincrement=False, nullable=True), + sa.Column( + "funcstat", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "aland", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "awater", + sa.DOUBLE_PRECISION(precision=53), + autoincrement=False, + nullable=True, + ), + sa.Column( + "intptlat", sa.VARCHAR(length=11), autoincrement=False, nullable=True + ), + sa.Column( + "intptlon", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + spatial_index=False, + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.CheckConstraint( + "geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", + name="enforce_geotype_geom", + ), + sa.CheckConstraint("st_ndims(the_geom) = 2", name="enforce_dims_geom"), + sa.CheckConstraint("st_srid(the_geom) = 4269", name="enforce_srid_geom"), + sa.PrimaryKeyConstraint("tabblock_id", name="tabblock_pkey"), + ) + + if alembic_helpers.table_does_not_exist("countysub_lookup"): + op.create_table( + "countysub_lookup", + sa.Column("st_code", sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column( + "state", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column("co_code", sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column( + "county", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.Column("cs_code", sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column( + "name", sa.VARCHAR(length=90), autoincrement=False, nullable=True + ), + sa.PrimaryKeyConstraint( + "st_code", "co_code", "cs_code", name="countysub_lookup_pkey" + ), + ) + op.create_index( + "countysub_lookup_state_idx", "countysub_lookup", ["state"], unique=False + ) + op.create_index( + "countysub_lookup_name_idx", + "countysub_lookup", + [sa.text("soundex(name::text)")], + unique=False, + ) + + if alembic_helpers.table_does_not_exist("addr"): + op.create_table( + "addr", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column("tlid", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column( + "fromhn", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "tohn", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column("side", sa.VARCHAR(length=1), autoincrement=False, nullable=True), + sa.Column("zip", sa.VARCHAR(length=5), autoincrement=False, nullable=True), + sa.Column( + "plus4", sa.VARCHAR(length=4), autoincrement=False, nullable=True + ), + sa.Column( + "fromtyp", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column( + "totyp", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column("fromarmid", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column("toarmid", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column( + "arid", sa.VARCHAR(length=22), autoincrement=False, nullable=True + ), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.PrimaryKeyConstraint("gid", name="addr_pkey"), + ) + op.create_index("idx_tiger_addr_zip", "addr", ["zip"], unique=False) + op.create_index( + "idx_tiger_addr_tlid_statefp", "addr", ["tlid", "statefp"], unique=False + ) + + if alembic_helpers.table_does_not_exist("voronois"): + op.create_table( + "voronois", + sa.Column("clusteruid", sa.TEXT(), autoincrement=False, nullable=True), + sa.Column( + "geom", + geoalchemy2.types.Geometry( + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + ) + op.create_index( + "voronois_idx", "voronois", ["geom"], unique=False, postgresql_using="gist" + ) + + if alembic_helpers.table_does_not_exist("state"): + op.create_table( + "state", + sa.Column("gid", sa.INTEGER(), autoincrement=True, nullable=False), + sa.Column( + "region", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "division", sa.VARCHAR(length=2), autoincrement=False, nullable=True + ), + sa.Column( + "statefp", sa.VARCHAR(length=2), autoincrement=False, nullable=False + ), + sa.Column( + "statens", sa.VARCHAR(length=8), autoincrement=False, nullable=True + ), + sa.Column( + "stusps", sa.VARCHAR(length=2), autoincrement=False, nullable=False + ), + sa.Column( + "name", sa.VARCHAR(length=100), autoincrement=False, nullable=True + ), + sa.Column("lsad", sa.VARCHAR(length=2), autoincrement=False, nullable=True), + sa.Column( + "mtfcc", sa.VARCHAR(length=5), autoincrement=False, nullable=True + ), + sa.Column( + "funcstat", sa.VARCHAR(length=1), autoincrement=False, nullable=True + ), + sa.Column("aland", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column("awater", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column( + "intptlat", sa.VARCHAR(length=11), autoincrement=False, nullable=True + ), + sa.Column( + "intptlon", sa.VARCHAR(length=12), autoincrement=False, nullable=True + ), + sa.Column( + "the_geom", + geoalchemy2.types.Geometry( + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.CheckConstraint( + "geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL", + name="enforce_geotype_the_geom", + ), + sa.CheckConstraint("st_ndims(the_geom) = 2", name="enforce_dims_the_geom"), + sa.CheckConstraint( + "st_srid(the_geom) = 4269", name="enforce_srid_the_geom" + ), + sa.PrimaryKeyConstraint("statefp", name="pk_tiger_state"), + sa.UniqueConstraint("gid", name="uidx_tiger_state_gid"), + sa.UniqueConstraint("stusps", name="uidx_tiger_state_stusps"), + ) + op.create_index( + "idx_tiger_state_the_geom_gist", + "state", + ["the_geom"], + unique=False, + postgresql_using="gist", + ) + + if alembic_helpers.table_does_not_exist("clusteredbuildings"): + op.create_table( + "clusteredbuildings", + sa.Column("id", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column("project_id", sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column("osm_id", sa.VARCHAR(), autoincrement=False, nullable=True), + sa.Column( + "geom", + geoalchemy2.types.Geometry( + geometry_type="POLYGON", + srid=4326, + from_text="ST_GeomFromEWKT", + name="geometry", + _spatial_index_reflected=True, + ), + autoincrement=False, + nullable=True, + ), + sa.Column( + "tags", + postgresql.JSONB(astext_type=sa.Text()), + autoincrement=False, + nullable=True, + ), + sa.Column("polyid", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column("numfeatures", sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column("cid", sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column("clusteruid", sa.TEXT(), autoincrement=False, nullable=True), + ) + op.create_index( + "clusteredbuildings_idx", + "clusteredbuildings", + ["geom"], + unique=False, + postgresql_using="gist", + ) + + if alembic_helpers.table_does_not_exist("loader_lookuptables"): + op.create_table( + "loader_lookuptables", + sa.Column( + "process_order", + sa.INTEGER(), + server_default=sa.text("1000"), + autoincrement=False, + nullable=False, + ), + sa.Column( + "lookup_name", + sa.TEXT(), + autoincrement=False, + nullable=False, + comment="This is the table name to inherit from and suffix of resulting output table -- how the table will be named -- edges here would mean -- ma_edges , pa_edges etc. except in the case of national tables. national level tables have no prefix", + ), + sa.Column( + "table_name", + sa.TEXT(), + autoincrement=False, + nullable=True, + comment="suffix of the tables to load e.g. edges would load all tables like *edges.dbf(shp) -- so tl_2010_42129_edges.dbf . ", + ), + sa.Column( + "single_mode", + sa.BOOLEAN(), + server_default=sa.text("true"), + autoincrement=False, + nullable=False, + ), + sa.Column( + "load", + sa.BOOLEAN(), + server_default=sa.text("true"), + autoincrement=False, + nullable=False, + comment="Whether or not to load the table. For states and zcta5 (you may just want to download states10, zcta510 nationwide file manually) load your own into a single table that inherits from tiger.states, tiger.zcta5. You'll get improved performance for some geocoding cases.", + ), + sa.Column( + "level_county", + sa.BOOLEAN(), + server_default=sa.text("false"), + autoincrement=False, + nullable=False, + ), + sa.Column( + "level_state", + sa.BOOLEAN(), + server_default=sa.text("false"), + autoincrement=False, + nullable=False, + ), + sa.Column( + "level_nation", + sa.BOOLEAN(), + server_default=sa.text("false"), + autoincrement=False, + nullable=False, + comment="These are tables that contain all data for the whole US so there is just a single file", + ), + sa.Column( + "post_load_process", sa.TEXT(), autoincrement=False, nullable=True + ), + sa.Column( + "single_geom_mode", + sa.BOOLEAN(), + server_default=sa.text("false"), + autoincrement=False, + nullable=True, + ), + sa.Column( + "insert_mode", + sa.CHAR(length=1), + server_default=sa.text("'c'::bpchar"), + autoincrement=False, + nullable=False, + ), + sa.Column( + "pre_load_process", sa.TEXT(), autoincrement=False, nullable=True + ), + sa.Column( + "columns_exclude", + postgresql.ARRAY(sa.TEXT()), + autoincrement=False, + nullable=True, + comment="List of columns to exclude as an array. This is excluded from both input table and output table and rest of columns remaining are assumed to be in same order in both tables. gid, geoid,cpi,suffix1ce are excluded if no columns are specified.", + ), + sa.Column( + "website_root_override", + sa.TEXT(), + autoincrement=False, + nullable=True, + comment="Path to use for wget instead of that specified in year table. Needed currently for zcta where they release that only for 2000 and 2010", + ), + sa.PrimaryKeyConstraint("lookup_name", name="loader_lookuptables_pkey"), ) # ### end Alembic commands ### @@ -796,82 +2044,110 @@ def upgrade() -> None: def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('loader_lookuptables') - op.drop_index('clusteredbuildings_idx', table_name='clusteredbuildings', postgresql_using='gist') - op.drop_table('clusteredbuildings') - op.drop_index('idx_tiger_state_the_geom_gist', table_name='state', postgresql_using='gist') - op.drop_table('state') - op.drop_index('voronois_idx', table_name='voronois', postgresql_using='gist') - op.drop_table('voronois') - op.drop_index('idx_tiger_addr_tlid_statefp', table_name='addr') - op.drop_index('idx_tiger_addr_zip', table_name='addr') - op.drop_table('addr') - op.drop_index('countysub_lookup_name_idx', table_name='countysub_lookup') - op.drop_index('countysub_lookup_state_idx', table_name='countysub_lookup') - op.drop_table('countysub_lookup') - op.drop_table('tabblock') - op.drop_index('taskpolygons_idx', table_name='taskpolygons', postgresql_using='gist') - op.drop_table('taskpolygons') - op.drop_index('street_type_lookup_abbrev_idx', table_name='street_type_lookup') - op.drop_table('street_type_lookup') - op.drop_table('layer') - op.drop_table('tract') - op.drop_table('zip_lookup_base') - op.drop_index('idx_tiger_county', table_name='county') - op.drop_table('county') - op.drop_table('loader_variables') - op.drop_index('idx_tiger_faces_countyfp', table_name='faces') - op.drop_index('idx_tiger_faces_tfid', table_name='faces') - op.drop_index('tiger_faces_the_geom_gist', table_name='faces', postgresql_using='gist') - op.drop_table('faces') - op.drop_index('idx_edges_tlid', table_name='edges') - op.drop_index('idx_tiger_edges_countyfp', table_name='edges') - op.drop_index('idx_tiger_edges_the_geom_gist', table_name='edges', postgresql_using='gist') - op.drop_table('edges') - op.drop_table('geocode_settings_default') - op.drop_table('bg') - op.drop_table('geocode_settings') - op.drop_index('county_lookup_name_idx', table_name='county_lookup') - op.drop_index('county_lookup_state_idx', table_name='county_lookup') - op.drop_table('county_lookup') - op.drop_table('zip_lookup') - op.drop_table('zip_state_loc') - op.drop_index('tiger_place_the_geom_gist', table_name='place', postgresql_using='gist') - op.drop_table('place') - op.drop_index('lowfeaturecountpolygons_idx', table_name='lowfeaturecountpolygons', postgresql_using='gist') - op.drop_table('lowfeaturecountpolygons') - op.drop_index('place_lookup_name_idx', table_name='place_lookup') - op.drop_index('place_lookup_state_idx', table_name='place_lookup') - op.drop_table('place_lookup') - op.drop_table('zip_state') - op.drop_index('tige_cousub_the_geom_gist', table_name='cousub', postgresql_using='gist') - op.drop_table('cousub') - op.drop_index('splitpolygons_idx', table_name='splitpolygons', postgresql_using='gist') - op.drop_table('splitpolygons') - op.drop_table('tabblock20') - op.drop_table('state_lookup') - op.drop_index('direction_lookup_abbrev_idx', table_name='direction_lookup') - op.drop_table('direction_lookup') - op.drop_table('pagc_gaz') - op.drop_index('secondary_unit_lookup_abbrev_idx', table_name='secondary_unit_lookup') - op.drop_table('secondary_unit_lookup') - op.drop_table('zcta5') - op.drop_index('buildings_idx', table_name='buildings', postgresql_using='gist') - op.drop_table('buildings') - op.drop_index('idx_tiger_featnames_lname', table_name='featnames') - op.drop_index('idx_tiger_featnames_snd_name', table_name='featnames') - op.drop_index('idx_tiger_featnames_tlid_statefp', table_name='featnames') - op.drop_table('featnames') - op.drop_table('topology') - op.drop_index('idx_addrfeat_geom_gist', table_name='addrfeat', postgresql_using='gist') - op.drop_index('idx_addrfeat_tlid', table_name='addrfeat') - op.drop_index('idx_addrfeat_zipl', table_name='addrfeat') - op.drop_index('idx_addrfeat_zipr', table_name='addrfeat') - op.drop_table('addrfeat') - op.drop_table('pagc_rules') - op.drop_table('zip_lookup_all') - op.drop_table('pagc_lex') - op.drop_index('dumpedpoints_idx', table_name='dumpedpoints', postgresql_using='gist') - op.drop_table('dumpedpoints') - op.drop_table('loader_platform') + op.drop_table("loader_lookuptables") + op.drop_index( + "clusteredbuildings_idx", + table_name="clusteredbuildings", + postgresql_using="gist", + ) + op.drop_table("clusteredbuildings") + op.drop_index( + "idx_tiger_state_the_geom_gist", table_name="state", postgresql_using="gist" + ) + op.drop_table("state") + op.drop_index("voronois_idx", table_name="voronois", postgresql_using="gist") + op.drop_table("voronois") + op.drop_index("idx_tiger_addr_tlid_statefp", table_name="addr") + op.drop_index("idx_tiger_addr_zip", table_name="addr") + op.drop_table("addr") + op.drop_index("countysub_lookup_name_idx", table_name="countysub_lookup") + op.drop_index("countysub_lookup_state_idx", table_name="countysub_lookup") + op.drop_table("countysub_lookup") + op.drop_table("tabblock") + op.drop_index( + "taskpolygons_idx", table_name="taskpolygons", postgresql_using="gist" + ) + op.drop_table("taskpolygons") + op.drop_index("street_type_lookup_abbrev_idx", table_name="street_type_lookup") + op.drop_table("street_type_lookup") + op.drop_table("layer") + op.drop_table("tract") + op.drop_table("zip_lookup_base") + op.drop_index("idx_tiger_county", table_name="county") + op.drop_table("county") + op.drop_table("loader_variables") + op.drop_index("idx_tiger_faces_countyfp", table_name="faces") + op.drop_index("idx_tiger_faces_tfid", table_name="faces") + op.drop_index( + "tiger_faces_the_geom_gist", table_name="faces", postgresql_using="gist" + ) + op.drop_table("faces") + op.drop_index("idx_edges_tlid", table_name="edges") + op.drop_index("idx_tiger_edges_countyfp", table_name="edges") + op.drop_index( + "idx_tiger_edges_the_geom_gist", table_name="edges", postgresql_using="gist" + ) + op.drop_table("edges") + op.drop_table("geocode_settings_default") + op.drop_table("bg") + op.drop_table("geocode_settings") + op.drop_index("county_lookup_name_idx", table_name="county_lookup") + op.drop_index("county_lookup_state_idx", table_name="county_lookup") + op.drop_table("county_lookup") + op.drop_table("zip_lookup") + op.drop_table("zip_state_loc") + op.drop_index( + "tiger_place_the_geom_gist", table_name="place", postgresql_using="gist" + ) + op.drop_table("place") + op.drop_index( + "lowfeaturecountpolygons_idx", + table_name="lowfeaturecountpolygons", + postgresql_using="gist", + ) + op.drop_table("lowfeaturecountpolygons") + op.drop_index("place_lookup_name_idx", table_name="place_lookup") + op.drop_index("place_lookup_state_idx", table_name="place_lookup") + op.drop_table("place_lookup") + op.drop_table("zip_state") + op.drop_index( + "tige_cousub_the_geom_gist", table_name="cousub", postgresql_using="gist" + ) + op.drop_table("cousub") + op.drop_index( + "splitpolygons_idx", table_name="splitpolygons", postgresql_using="gist" + ) + op.drop_table("splitpolygons") + op.drop_table("tabblock20") + op.drop_table("state_lookup") + op.drop_index("direction_lookup_abbrev_idx", table_name="direction_lookup") + op.drop_table("direction_lookup") + op.drop_table("pagc_gaz") + op.drop_index( + "secondary_unit_lookup_abbrev_idx", table_name="secondary_unit_lookup" + ) + op.drop_table("secondary_unit_lookup") + op.drop_table("zcta5") + op.drop_index("buildings_idx", table_name="buildings", postgresql_using="gist") + op.drop_table("buildings") + op.drop_index("idx_tiger_featnames_lname", table_name="featnames") + op.drop_index("idx_tiger_featnames_snd_name", table_name="featnames") + op.drop_index("idx_tiger_featnames_tlid_statefp", table_name="featnames") + op.drop_table("featnames") + op.drop_table("topology") + op.drop_index( + "idx_addrfeat_geom_gist", table_name="addrfeat", postgresql_using="gist" + ) + op.drop_index("idx_addrfeat_tlid", table_name="addrfeat") + op.drop_index("idx_addrfeat_zipl", table_name="addrfeat") + op.drop_index("idx_addrfeat_zipr", table_name="addrfeat") + op.drop_table("addrfeat") + op.drop_table("pagc_rules") + op.drop_table("zip_lookup_all") + op.drop_table("pagc_lex") + op.drop_index( + "dumpedpoints_idx", table_name="dumpedpoints", postgresql_using="gist" + ) + op.drop_table("dumpedpoints") + op.drop_table("loader_platform") # ### end Alembic commands ###