cockroachdb / cockroachdb/django-cockroachdb
Migration error: `column "form_data" cannot be cast automatically to type JSONB`
- Dominant language
- Python
- Stars
- 174
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
Trying to migrate from PostgreSQL to CockroachDB (v24.2.0) presents a unique error. I am using `django-cockroachdb==5.0` as I am unable to upgrade django to 5.1 (using django 5.0.9).
This is being caused by an upstream migration see here: https://github.com/coderedcorp/coderedcms/blob/8e04513572498603a6f64968bb88fd7aed7cd63c/coderedcms/migrations/0031_wagtail3.py#L25C9-L29C11
I'm just running `python manage.py migrate` as I would with Postgres.
Full traceback:
```python-traceback
Running migrations:
Applying coderedcms.0031_wagtail3...Traceback (most recent call last):
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/backends/utils.py", line 103, in _execute
return self.cursor.execute(sql)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
raise ex.with_traceback(None)
psycopg.errors.DatatypeMismatch: column "form_data" cannot be cast automatically to type JSONB
HINT: You might need to specify "USING form_data::JSONB".
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/app/manage.py", line 22, in
execute_from_command_line(sys.argv)
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/core/management/base.py", line 107, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/core/management/commands/migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
^^^^^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/migrations/migration.py", line 132, in apply
operation.database_forwards(
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/migrations/operations/fields.py", line 235, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/backends/base/schema.py", line 906, in alter_field
self._alter_field(
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django_cockroachdb/schema.py", line 63, in _alter_field
BaseDatabaseSchemaEditor._alter_field(
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/backends/base/schema.py", line 1163, in _alter_field
self.execute(
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/backends/postgresql/schema.py", line 48, in execute
return super().execute(sql, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/backends/base/schema.py", line 202, in execute
cursor.execute(sql, params)
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/backends/utils.py", line 122, in execute
return super().execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/backends/utils.py", line 79, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/backends/utils.py", line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/backends/utils.py", line 100, in _execute
with self.db.wrap_database_errors:
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/django/db/backends/utils.py", line 103, in _execute
return self.cursor.execute(sql)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/dev-user/.cache/pypoetry/virtualenvs/dtautomation-9TtSrW0h-py3.12/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
raise ex.with_traceback(None)
django.db.utils.ProgrammingError: column "form_data" cannot be cast automatically to type JSONB
HINT: You might need to specify "USING form_data::JSONB".
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.