Skip to content

Commit

Permalink
Merge pull request #4996 from legiongis/cherry_pick_PR_4945_to_master
Browse files Browse the repository at this point in the history
Cherry pick pr 4945 to master
  • Loading branch information
mradamcox committed Jul 11, 2019
2 parents d5df55f + 5560fd2 commit d0e0b71
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion arches/management/commands/setup_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,22 @@ def drop_and_recreate_db(self, cursor):
CONNECTION LIMIT=-1
TEMPLATE = {};""".format(arches_db['NAME'], arches_db['USER'], arches_db['POSTGIS_TEMPLATE'])
print(create_query+"\n")
cursor.execute(create_query)

try:
cursor.execute(create_query)
except psycopg2.ProgrammingError as e:
print(e.pgerror)
if "template database" in e.pgerror:
msg = """It looks like your PostGIS template database is not correctly referenced in
settings.py/settings_local.py, or it has not yet been created.
To create it, use:
psql -U {0} -c "CREATE DATABASE {1};"
psql -U {0} -d {1} -c "CREATE EXTENSION postgis;"
""".format(arches_db['USER'], arches_db['POSTGIS_TEMPLATE'])
print(msg)
exit()

def setup_db(self):
"""
Expand Down

0 comments on commit d0e0b71

Please sign in to comment.