Changes between Initial Version and Version 1 of Ticket #26777
- Timestamp:
- Jun 18, 2016, 9:52:04 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #26777
- Property Resolution → needsinfo
- Property Status new → closed
- Property Type Uncategorized → Bug
-
Ticket #26777 – Description
initial v1 1 1 I have a model that looks like 2 2 3 {{{#!python 4 class LiveEvent(models.Model): 5 id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) 6 ... 7 attendees = models.ManyToManyField( 8 User, blank=True, related_name="events_attended" 9 ) 10 ... 11 notify_subscriptions = models.ManyToManyField( 12 User, blank=True, related_name="events_subscribed" 13 ) 14 }}} 15 16 when trying to add and migrate notify_subscriptions field I get the following error: 17 {{{ 18 django.db.utils.IntegrityError: (1215, 'Cannot add foreign key constraint')` 19 }}} 20 21 When adding 22 23 {{{#!python 24 'OPTIONS': { 25 "init_command": "SET foreign_key_checks = 0;", 26 }, 27 }}} 28 29 to database settings , the error became: 3 30 4 31 {{{ 5 class LiveEvent(models.Model): 6 id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) 7 8 ... 9 10 attendees = models.ManyToManyField(User, blank=True, related_name="events_attended") 11 12 ... 13 14 notify_subscriptions = models.ManyToManyField(User, blank=True, related_name="events_subscribed") 15 32 django.db.utils.OperationalError: (1825, "Failed to add the foreign key constraint on table 'levan_liveevent_notify_subscriptions'. Incorrect options in FOREIGN KEY constraint 'slipmat/levan_liveevent_noti_liveevent_id_a4871abc_fk_levan_liveevent_id'") 16 33 }}} 17 18 when trying to add and migrate notify_subscriptions field I get an `django.db.utils.IntegrityError: (1215, 'Cannot add foreign key constraint')` error. When adding19 20 {{{21 22 'OPTIONS': {23 "init_command": "SET foreign_key_checks = 0;",24 },25 }}}26 27 to database settings , the error becames: `django.db.utils.OperationalError: (1825, "Failed to add the foreign key constraint on table 'levan_liveevent_notify_subscriptions'. Incorrect options in FOREIGN KEY constraint 'slipmat/levan_liveevent_noti_liveevent_id_a4871abc_fk_levan_liveevent_id'")`28 34 29 35 the migration file looks like: 30 36 31 {{{ 32 33 operations = [34 m igrations.AddField(35 model_name='liveevent',36 name='notify_subscriptions',37 field=models.ManyToManyField(blank=True, related_name='events_subscribed', to=settings.AUTH_USER_MODEL),37 {{{#!python 38 operations = [ 39 migrations.AddField( 40 model_name='liveevent', 41 name='notify_subscriptions', 42 field=models.ManyToManyField( 43 blank=True, related_name='events_subscribed', to=settings.AUTH_USER_MODEL 38 44 ), 39 ]40 45 ), 46 ] 41 47 }}} 42 48