nakagami / djfirebirdsql

Django Firebird database backend
BSD 3-Clause "New" or "Revised" License
10 stars 5 forks source link

Cannot update index segment used by an Integrity Constraint #8

Open elasticdotventures opened 3 years ago

elasticdotventures commented 3 years ago

Trying to migrate an existing Django application from mssql/odbc to firebird Any suggestions how to troubleshoot is appreciated.

Firebird 4.0rc1 running in docker container on port 3050 Django 3.1.6 latest firebirdsql & djfirebirdsql i.e.: git+git://github.com/nakagami/djfirebirdsql#djfirebirdsql git+git://github.com/nakagami/pyfirebirdsql#firebirdsql

./manage.py migrate auth

File "/usr/local/lib/python3.8/dist-packages/firebirdsql/wireprotocol.py", line 305, in _parse_op_response raise OperationalError(message, gds_codes, sql_code) firebirdsql.OperationalError: ALTER TABLE "AUTH_USER" ALTER "USERNAME" TYPE varchar(150): unsuccessful metadata update ALTER TABLE AUTH_USER failed action cancelled by trigger (1) to preserve data integrity Cannot update index segment used by an Integrity Constraint

....

django.db.utils.OperationalError: ('unsuccessful metadata update\nALTER TABLE AUTH_USER failed\naction cancelled by trigger (1) to preserve data integrity\nCannot update index segment used by an Integrity Constraint\n', 0)

elasticdotventures commented 3 years ago

Relevant file: https://github.com/django/django/blob/main/django/contrib/auth/migrations/0008_alter_user_username_max_length.py

nakagami commented 3 years ago

Sorry, this software is incomplete and has many other bugs. I'm trying to keep up with Django 3.2, but so far I haven't had a chance. There are no plans to fix the bugs in 3.1.

devops724 commented 2 years ago

$ python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions, sites Running migrations: Applying auth.0008_alter_user_username_max_length...Traceback (most recent call last): File "/home/user/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/home/user/env/lib/python3.9/site-packages/djfirebirdsql/cursor.py", line 70, in execute raise e File "/home/user/env/lib/python3.9/site-packages/djfirebirdsql/cursor.py", line 67, in execute super().execute(self.query) File "/home/user/env/lib/python3.9/site-packages/firebirdsql/fbcore.py", line 327, in execute (h, oid, buf) = self.transaction.connection._op_response() File "/home/user/env/lib/python3.9/site-packages/firebirdsql/wireprotocol.py", line 1146, in _op_response return self._parse_op_response() File "/home/user/env/lib/python3.9/site-packages/firebirdsql/wireprotocol.py", line 307, in _parse_op_response raise OperationalError(message, gds_codes, sql_code) firebirdsql.OperationalError: ALTER TABLE "AUTH_USER" ALTER "USERNAME" TYPE varchar(150): unsuccessful metadata update ALTER TABLE AUTH_USER failed action cancelled by trigger (1) to preserve data integrity Cannot update index segment used by an Integrity Constraint

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

Traceback (most recent call last): File "/home/user/server/manage.py", line 33, in main() File "/home/user/server/manage.py", line 29, in main execute_from_command_line(sys.argv) File "/home/user/env/lib/python3.9/site-packages/django/core/management/init.py", line 401, in execute_from_command_line utility.execute() File "/home/user/env/lib/python3.9/site-packages/django/core/management/init.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/user/env/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv self.execute(*args, cmd_options) File "/home/user/env/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute output = self.handle(*args, *options) File "/home/user/env/lib/python3.9/site-packages/django/core/management/base.py", line 85, in wrapped res = handle_func(args, kwargs) File "/home/user/env/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 243, in handle post_migrate_state = executor.migrate( File "/home/user/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/home/user/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/home/user/env/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration state = migration.apply(state, schema_editor) File "/home/user/env/lib/python3.9/site-packages/django/db/migrations/migration.py", line 124, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/home/user/env/lib/python3.9/site-packages/django/db/migrations/operations/fields.py", line 236, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File "/home/user/env/lib/python3.9/site-packages/djfirebirdsql/schema.py", line 71, in alter_field raise e File "/home/user/env/lib/python3.9/site-packages/djfirebirdsql/schema.py", line 68, in alter_field super().alter_field(model, old_field, new_field, False) File "/home/user/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 571, in alter_field self._alter_field(model, old_field, new_field, old_type, new_type, File "/home/user/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 721, in _alter_field self.execute( File "/home/user/env/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 142, in execute cursor.execute(sql, params) File "/home/user/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 98, in execute return super().execute(sql, params) File "/home/user/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/home/user/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers return executor(sql, params, many, context) File "/home/user/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/home/user/env/lib/python3.9/site-packages/django/db/utils.py", line 90, in exit raise dj_exc_value.with_traceback(traceback) from exc_value File "/home/user/env/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/home/user/env/lib/python3.9/site-packages/djfirebirdsql/cursor.py", line 70, in execute raise e File "/home/user/env/lib/python3.9/site-packages/djfirebirdsql/cursor.py", line 67, in execute super().execute(self.query) File "/home/user/env/lib/python3.9/site-packages/firebirdsql/fbcore.py", line 327, in execute (h, oid, buf) = self.transaction.connection._op_response() File "/home/user/env/lib/python3.9/site-packages/firebirdsql/wireprotocol.py", line 1146, in _op_response return self._parse_op_response() File "/home/user/env/lib/python3.9/site-packages/firebirdsql/wireprotocol.py", line 307, in _parse_op_response raise OperationalError(message, gds_codes, sql_code) django.db.utils.OperationalError: ('unsuccessful metadata update\nALTER TABLE AUTH_USER failed\naction cancelled by trigger (1) to preserve data integrity\nCannot update index segment used by an Integrity Constraint\n', 0)

django==3.1 latest djfirebirdsql

nakagami commented 2 years ago

Sorry I haven't maintained this for so long.

The django version keeps going up and up and up and I'm tired of it. I may pop back and fix things for the latest version of django, but I don't think I'll be able to do anything for a while.

I wish Django would do a builtin Firebird backend!