hotosm/tasking-manager

Problems with migrate model to DB

Closed this issue · 0 comments

We have problems on migrate model to DB.

These are the steps we execute to impact the model in the database:

1- cp example.env tasking-manager.env
2- set cllient ID and secret ID on tasking-manager.env
3- Docker compose up -d
4- docker exec -it tasking-manager-main-tm-backend-1 bash
5- python manage.py db migrate
6- python manage.py db upgrade (ERROR on this step )

LOG ERROR:

/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/functions.py:112: SAWarning: The GenericFunction 'st_setsrid' is already registered and is going to be overridden.
super().init_subclass()
/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/functions.py:112: SAWarning: The GenericFunction 'st_geomfromgeojson' is already registered and is going to be overridden.
super().init_subclass()
/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/functions.py:112: SAWarning: The GenericFunction 'st_centroid' is already registered and is going to be overridden.
super().init_subclass()
/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/functions.py:112: SAWarning: The GenericFunction 'st_transform' is already registered and is going to be overridden.
super().init_subclass()
/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/functions.py:112: SAWarning: The GenericFunction 'st_area' is already registered and is going to be overridden.
super().init_subclass()
/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/functions.py:112: SAWarning: The GenericFunction 'st_geogfromwkb' is already registered and is going to be overridden.
super().init_subclass()
/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/functions.py:112: SAWarning: The GenericFunction 'st_buffer' is already registered and is going to be overridden.
super().init_subclass()
/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/functions.py:112: SAWarning: The GenericFunction 'st_intersects' is already registered and is going to be overridden.
super().init_subclass()
/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/functions.py:112: SAWarning: The GenericFunction 'st_makeenvelope' is already registered and is going to be overridden.
super().init_subclass()
/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/functions.py:112: SAWarning: The GenericFunction 'st_x' is already registered and is going to be overridden.
super().init_subclass()
/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/functions.py:112: SAWarning: The GenericFunction 'st_y' is already registered and is going to be overridden.
super().init_subclass()
/usr/src/app/manage.py:37: UserWarning: TM_DEFAULT_CHANGESET_COMMENT environmental variable not set.
warnings.warn("%s environmental variable not set." % (key,))
[2024-04-26 18:20:46,280] INFO in init: Starting up a new Tasking Manager application
[2024-04-26 18:20:46,280] DEBUG in init: Connecting to the database
[2024-04-26 18:20:46,330] DEBUG in init: Add root redirect route
[2024-04-26 18:20:46,332] DEBUG in init: Adding routes to API endpoints
[2024-04-26 18:20:50,220] DEBUG in manage: Initiated background thread to auto unlock tasks
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade 42c45e74752b -> 652eb359ceec, empty message
Traceback (most recent call last):
File "/home/appuser/.local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1965, in _exec_single_context
self.dialect.do_execute(
File "/home/appuser/.local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 921, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.DependentObjectsStillExist: cannot drop table place because extension postgis_tiger_geocoder requires it
HINT: You can drop extension postgis_tiger_geocoder instead.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/app/manage.py", line 154, in
cli()
File "/home/appuser/.local/lib/python3.10/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/home/appuser/.local/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/home/appuser/.local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/appuser/.local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/appuser/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/appuser/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/appuser/.local/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/appuser/.local/lib/python3.10/site-packages/flask/cli.py", line 357, in decorator
return __ctx.invoke(f, *args, **kwargs)
File "/home/appuser/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/appuser/.local/lib/python3.10/site-packages/flask_migrate/cli.py", line 150, in upgrade
_upgrade(directory, revision, sql, tag, x_arg)
File "/home/appuser/.local/lib/python3.10/site-packages/flask_migrate/init.py", line 111, in wrapped
f(*args, **kwargs)
File "/home/appuser/.local/lib/python3.10/site-packages/flask_migrate/init.py", line 200, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/command.py", line 385, in upgrade
script.run_env()
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/script/base.py", line 582, in run_env
util.load_python_file(self.dir, "env.py")
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 94, in load_python_file
module = load_module_py(module_id, path)
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 110, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "", line 883, in exec_module
File "", line 241, in call_with_frames_removed
File "/usr/src/app/migrations/env.py", line 119, in
run_migrations_online()
File "/usr/src/app/migrations/env.py", line 111, in run_migrations_online
context.run_migrations()
File "", line 8, in run_migrations
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/runtime/environment.py", line 928, in run_migrations
self.get_context().run_migrations(**kw)
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/runtime/migration.py", line 628, in run_migrations
step.migration_fn(**kw)
File "/usr/src/app/migrations/versions/652eb359ceec
.py", line 37, in upgrade
op.drop_geospatial_table('place')
File "", line 8, in drop_geospatial_table
File "", line 3, in drop_geospatial_table
File "/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/alembic_helpers.py", line 454, in drop_geospatial_table
return operations.invoke(op)
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/operations/base.py", line 395, in invoke
return fn(self, operation)
File "/home/appuser/.local/lib/python3.10/site-packages/geoalchemy2/alembic_helpers.py", line 507, in drop_geospatial_table
operations.drop_table(table_name, schema=operation.schema, **operation.table_kw)
File "", line 3, in drop_table
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/operations/ops.py", line 1374, in drop_table
operations.invoke(op)
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/operations/base.py", line 395, in invoke
return fn(self, operation)
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/operations/toimpl.py", line 79, in drop_table
operations.impl.drop_table(
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/ddl/impl.py", line 377, in drop_table
self._exec(schema.DropTable(table))
File "/home/appuser/.local/lib/python3.10/site-packages/alembic/ddl/impl.py", line 193, in _exec
return conn.execute( # type: ignore[call-overload]
File "/home/appuser/.local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1412, in execute
return meth(
File "/home/appuser/.local/lib/python3.10/site-packages/sqlalchemy/sql/ddl.py", line 181, in _execute_on_connection
return connection._execute_ddl(
File "/home/appuser/.local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1524, in _execute_ddl
ret = self._execute_context(
File "/home/appuser/.local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1844, in _execute_context
return self._exec_single_context(
File "/home/appuser/.local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1984, in _exec_single_context
self._handle_dbapi_exception(
File "/home/appuser/.local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2339, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/home/appuser/.local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1965, in _exec_single_context
self.dialect.do_execute(
File "/home/appuser/.local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 921, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.InternalError: (psycopg2.errors.DependentObjectsStillExist) cannot drop table place because extension postgis_tiger_geocoder requires it
HINT: You can drop extension postgis_tiger_geocoder instead.

[SQL:
DROP TABLE place]
(Background on this error at: https://sqlalche.me/e/20/2j85)

Any suggest?

Thanks!