Migrate to mongodb is failing

279 views
Skip to first unread message

Fábio Barboza de Freitas

unread,
Sep 12, 2022, 9:53:32 AM9/12/22
to Django users
I'm trying to migrate the django tables to mongo, but it is the error I get:

Applying contenttypes.0002_remove_content_type_name...This version of djongo does not support "DROP CASCADE" fully. Visit https://nesdis.github.io/djongo/support/
Traceback (most recent call last):
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 857, in parse
    return handler(self, statement)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 894, in _alter
    query.execute()
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 533, in _drop_column
    self.db[self.left_table].update(
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/pymongo/collection.py", line 3200, in __call__
    raise TypeError(
TypeError: 'Collection' object is not callable. If you meant to call the 'update' method on a 'Collection' object it is failing because no such method exists.

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

Traceback (most recent call last):
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/djongo/cursor.py", line 51, in execute
    self.result = Query(
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 784, in __init__
    self._query = self.parse()
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/djongo/sql2mongo/query.py", line 885, in parse
    raise exe from e
djongo.exceptions.SQLDecodeError:

        Keyword: None
        Sub SQL: None
        FAILED SQL: ALTER TABLE "django_content_type" DROP COLUMN "name" CASCADE
        Params: ()
        Version: 1.3.6

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

Traceback (most recent call last):
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/djongo/cursor.py", line 59, in execute
    raise db_exe from e
djongo.database.DatabaseError

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

Traceback (most recent call last):
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/core/management/base.py", line 96, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 349, in handle
    post_migrate_state = executor.migrate(
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/migrations/migration.py", line 130, in apply
    operation.database_forwards(
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/migrations/operations/fields.py", line 170, in database_forwards
    schema_editor.remove_field(
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 722, in remove_field
    self.execute(sql)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 199, in execute
    cursor.execute(sql, params)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 103, in execute
    return super().execute(sql, params)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/djongo/cursor.py", line 59, in execute
    raise db_exe from e
django.db.utils.DatabaseError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fabio/Documentos/In8/ProjectsRobos/Relatorios_API/manage.py", line 28, in <module>
    main()
  File "/home/fabio/Documentos/In8/ProjectsRobos/Relatorios_API/manage.py", line 24, in main
    execute_from_command_line(sys.argv)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/core/management/base.py", line 415, in run_from_argv
    connections.close_all()
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/utils/connection.py", line 85, in close_all
    conn.close()
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/django/db/backends/base/base.py", line 358, in close
    self._close()
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/djongo/base.py", line 208, in _close
    if self.connection:
  File "/home/fabio/Documentos/In8/ProjectsRobos/API_Relatorios/venv/lib/python3.10/site-packages/pymongo/database.py", line 1155, in __bool__
    raise NotImplementedError(
NotImplementedError: Database objects do not implement truth value testing or bool(). Please compare with None instead: database is not None

Can anyone help plz?

Ryan Nowakowski

unread,
Sep 12, 2022, 8:00:10 PM9/12/22
to django...@googlegroups.com


On September 12, 2022 7:38:21 AM EST, "Fábio Barboza de Freitas" <fabio....@in8.com.br> wrote:
>I'm trying to migrate the django tables to mongo, but it is the error I get:
>
>Applying contenttypes.0002_remove_content_type_name...This version of
>djongo does not support "DROP CASCADE" fully. Visit
>https://nesdis.github.io/djongo/support/

Any luck with the documentation on that support page?

subin

unread,
Sep 16, 2022, 4:59:51 PM9/16/22
to django...@googlegroups.com
Sorry to write again so quickly.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9309410B-06E1-4AFF-96EF-8B9A76C72AD1%40fattuba.com.
Reply all
Reply to author
Forward
0 new messages