Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions docker/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ def prepare_pgosm_db(data_only, db_path, append):

create_pgosm_db()
else:
LOGGER.info('Using external database. Ensure the target database is setup properly for PgOSM Flex with PostGIS, osm schema, and proper permissions.')
LOGGER.info('Using external database. Ensure the target database is setup properly with proper permissions.')

prepare_pgosm_schema()

if not data_only:
LOGGER.info('Loading extras via Sqitch plus QGIS styles.')
Expand Down Expand Up @@ -283,6 +285,7 @@ def create_pgosm_db():

LOGGER.debug('Setting Pg conn to enable autocommit - required for drop/create DB')
conn.autocommit = True

try:
conn.execute(sql_raw)
LOGGER.info('Created pgosm database')
Expand All @@ -291,6 +294,12 @@ def create_pgosm_db():
finally:
conn.close()

return True


def prepare_pgosm_schema():
"""Prepares the database with PostGIS and osm schema
"""
sql_create_postgis = "CREATE EXTENSION IF NOT EXISTS postgis;"
sql_create_schema = "CREATE SCHEMA IF NOT EXISTS osm;"

Expand All @@ -301,8 +310,6 @@ def create_pgosm_db():
cur.execute(sql_create_schema)
LOGGER.debug('Created osm schema')

return True


def run_sqitch_prep(db_path):
"""Runs Sqitch to create DB structure and populate helper data.
Expand Down