Modify

Ticket #946 (new defect)

Opened 3 years ago

Last modified 3 years ago

ORM does not cascade deletion of rows across apps

Reported by: stucchio@… Owned by: andrew
Priority: minor Milestone: 1.0
Component: commands Version: 0.7.3
Keywords: Cc:

Description

I'm using django south 0.7.3, and I'm running into the following error.

I have django application A, with model Foo.

I have django application B, with model Bar. Bar.foo is a foreign key pointing to an instance of Foo.

I created a data migration which deletes some Foo objects. However, the migration fails with the error copied below. The behavior I expected is that deletion of a food object would result in a cascading delete of all bar objects which reference it.

This is related to ticket #165, though I believe ticket #165 occurred when both Foo and Bar were contained in app A.

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/management/commands/migrate.py", line 107, in handle
    ignore_ghosts = ignore_ghosts,
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/__init__.py", line 191, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 222, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 293, in migrate_many
    result = self.migrate(migration, database)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 126, in migrate
    result = self.run(migration)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 100, in run
    return self.run_migration(migration)
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/migrators.py", line 90, in run_migration
    south.db.db.commit_transaction()
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/db/generic.py", line 854, in commit_transaction
    transaction.commit()
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/transaction.py", line 142, in commit
    connection.commit()
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/backends/__init__.py", line 201, in commit
    self._commit()
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/backends/postgresql_psycopg2/base.py", line 200, in _commit
    return self.connection.commit()
django.db.utils.IntegrityError: update or delete on table "a_foo" violates foreign key constraint "foo_id_refs_id_190d3aa60668023d" on table "b_bar"
DETAIL:  Key (id)=(130820) is still referenced from table "b__bar".

Attachments

Change History

comment:1 Changed 3 years ago by andrew

  • Milestone set to 1.0
View

Add a comment

Modify Ticket

Action
as new
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.