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:


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. 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 "", line 11, in <module>
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/management/", line 438, in execute_manager
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/management/", line 379, in execute
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/core/management/", 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/", 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/", 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/", 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/", 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/", 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/", line 126, in migrate
    result =
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/migration/", 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/", line 90, in run_migration
  File "/usr/local/lib/python2.6/dist-packages/South-0.7.3-py2.6.egg/south/db/", line 854, in commit_transaction
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/", line 142, in commit
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/backends/", line 201, in commit
  File "/usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/db/backends/postgresql_psycopg2/", 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".


Change History

comment:1 Changed 3 years ago by andrew

  • Milestone set to 1.0

Add a comment

Modify Ticket

as new

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

Note: See TracTickets for help on using tickets.