Add PostGIS initialization to installation process
See original GitHub issueWhile installing, I see this error when the manage.py db upgrade
command is run. Should I be doing something differently?
+ ./venv/bin/python3.6 manage.py db upgrade
##################### loading env
manage.py:34: UserWarning: Homepage counters not initialized.
warnings.warn('Homepage counters not initialized.')
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> 8aa8f8d6a0c3, empty message
Traceback (most recent call last):
File "/tasking-manager/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
context)
File "/tasking-manager/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
cursor.execute(statement, parameters)
psycopg2.ProgrammingError: type "geometry" does not exist
LINE 4: geometry geometry(MULTIPOLYGON,4326),
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 59, in <module>
manager.run()
File "/tasking-manager/venv/lib/python3.6/site-packages/flask_script/__init__.py", line 412, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/tasking-manager/venv/lib/python3.6/site-packages/flask_script/__init__.py", line 383, in handle
res = handle(*args, **config)
File "/tasking-manager/venv/lib/python3.6/site-packages/flask_script/commands.py", line 216, in __call__
return self.run(*args, **kwargs)
File "/tasking-manager/venv/lib/python3.6/site-packages/flask_migrate/__init__.py", line 247, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/tasking-manager/venv/lib/python3.6/site-packages/alembic/command.py", line 254, in upgrade
script.run_env()
File "/tasking-manager/venv/lib/python3.6/site-packages/alembic/script/base.py", line 421, in run_env
util.load_python_file(self.dir, 'env.py')
File "/tasking-manager/venv/lib/python3.6/site-packages/alembic/util/pyfiles.py", line 93, in load_python_file
module = load_module_py(module_id, path)
File "/tasking-manager/venv/lib/python3.6/site-packages/alembic/util/compat.py", line 64, in load_module_py
module_id, path).load_module(module_id)
File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 823, in load_module
File "<frozen importlib._bootstrap_external>", line 682, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 684, in _load
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "migrations/env.py", line 99, in <module>
run_migrations_online()
File "migrations/env.py", line 92, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/tasking-manager/venv/lib/python3.6/site-packages/alembic/runtime/environment.py", line 817, in run_migrations
self.get_context().run_migrations(**kw)
File "/tasking-manager/venv/lib/python3.6/site-packages/alembic/runtime/migration.py", line 329, in run_migrations
step.migration_fn(**kw)
File "/tasking-manager/migrations/versions/8aa8f8d6a0c3_.py", line 27, in upgrade
sa.PrimaryKeyConstraint('id')
File "<string>", line 8, in create_table
File "<string>", line 3, in create_table
File "/tasking-manager/venv/lib/python3.6/site-packages/alembic/operations/ops.py", line 1106, in create_table
return operations.invoke(op)
File "/tasking-manager/venv/lib/python3.6/site-packages/alembic/operations/base.py", line 318, in invoke
return fn(self, operation)
File "/tasking-manager/venv/lib/python3.6/site-packages/alembic/operations/toimpl.py", line 101, in create_table
operations.impl.create_table(table)
File "/tasking-manager/venv/lib/python3.6/site-packages/alembic/ddl/impl.py", line 194, in create_table
self._exec(schema.CreateTable(table))
File "/tasking-manager/venv/lib/python3.6/site-packages/alembic/ddl/impl.py", line 118, in _exec
return conn.execute(construct, *multiparams, **params)
File "/tasking-manager/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 945, in execute
return meth(self, multiparams, params)
File "/tasking-manager/venv/lib/python3.6/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/tasking-manager/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1002, in _execute_ddl
compiled
File "/tasking-manager/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
context)
File "/tasking-manager/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
exc_info
File "/tasking-manager/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/tasking-manager/venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
raise value.with_traceback(tb)
File "/tasking-manager/venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
context)
File "/tasking-manager/venv/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) type "geometry" does not exist
LINE 4: geometry geometry(MULTIPOLYGON,4326),
^
[SQL: '\nCREATE TABLE areas_of_interest (\n\tid SERIAL NOT NULL, \n\tgeometry geometry(MULTIPOLYGON,4326), \n\tcentroid geometry(POINT,4326), \n\tPRIMARY KEY (id)\n)\n\n']
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Chapter 2. PostGIS Installation
This chapter details the steps required to install PostGIS. ... This section includes general compilation instructions, if you are compiling for Windows etc ......
Read more >How to install PostGIS on Mac OS X - MORPHOCODE
In this tutorial, we will see how to install PostGIS on Mac OS X. We'll use ... If that's a fresh installation, we...
Read more >postgres 11.2 installation with postGIS extension - YouTube
This video includes installation process of postgresql with spatial postgis extension. Also includes simple spatial query.
Read more >How to Setup a PostGIS Database on Windows from Scratch
No-installation PostgreSQL Setup · Initialize the PostgreSQL Storage Area · Connect to PostgreSQL with pgAdmin · Create Roles · Create the PostGIS ......
Read more >Installing postgis on postgresql 9.1 not working
By doing CREATE EXTENSION postgis; you're trying to initialize from PostgreSQL with the ... sudo apt-get install postgresql-9.1-postgis-2.0.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@arunasank the solution is to enable the extension. You need to connect to the database and run
Then you run migrations again.
I think it is possible, one solution might be to add a command within
manage.py
to execute os-based commands for psql likeBecause they are shell commands, if you have the ability run them without python, would be better for debugging
Now, if you necessarily need to run the database creation with
python manage.py db upgrade
it would imply to create a new class in python which inherits fromMigrateCommand
class from flask-migrate module to include the commands above before executing original methods, using super. Like this:https://github.com/boundlessgeo/registry/blob/master/registry.py#L561