Re: [Django] #35416: Removing a primary_key field causes a migration crash

2024-04-30 Thread Django
#35416: Removing a primary_key field causes a migration crash
-+--
 Reporter:  Sarah Boyce  |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:  duplicate
 Keywords:   | Triage Stage:  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+--
Changes (by Sarah Boyce):

 * resolution:   => duplicate
 * status:  new => closed

Comment:

 Thank you for verifying - duplicate of #22997.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f2f7a0870-89c78202-8c71-4a44-9da3-ac459a8e155a-00%40eu-central-1.amazonses.com.


Re: [Django] #35416: Removing a primary_key field causes a migration crash

2024-04-30 Thread Django
#35416: Removing a primary_key field causes a migration crash
-+--
 Reporter:  Sarah Boyce  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+--
Comment (by Simon Charette):

 I would qualify this as a duplicate of #22997 as changing a model from

 {{{#!python
 class MySimpleModel(models.Model):
 some_pk = models.IntegerField(primary_key=True)
 }}}

 to

 {{{#!python
 class MySimpleModel(models.Model):
 pass
 }}}

 Is exactly ''removing an explicit primary key''.

 The ticket also describes the questioner asking about providing a default
 value.

 I think that your first instinct was right, this is the same issue which
 is not specific to Postgres.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f2f6377e2-1c2ac120-7426-4aa2-b1ab-dd39d18722e9-00%40eu-central-1.amazonses.com.


Re: [Django] #35416: Removing a primary_key field causes a migration crash

2024-04-30 Thread Django
#35416: Removing a primary_key field causes a migration crash
-+--
 Reporter:  Sarah Boyce  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Migrations   |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+--
Changes (by Sarah Boyce):

 * type:  Uncategorized => Bug

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f2ee82758-5cd68772-64df-4114-9929-901cd431db59-00%40eu-central-1.amazonses.com.


[Django] #35416: Removing a primary_key field causes a migration crash

2024-04-30 Thread Django
#35416: Removing a primary_key field causes a migration crash
-+
   Reporter:  Sarah Boyce|  Owner:  nobody
   Type:  Uncategorized  | Status:  new
  Component:  Migrations |Version:  dev
   Severity:  Normal |   Keywords:
   Triage Stage:  Unreviewed |  Has patch:  0
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+
 [I am using SQLite]

 Create a model with a primary_key field and makemigrations and migrate
 {{{#!python
 from django.db import models


 class MySimpleModel(models.Model):
 some_pk = models.IntegerField(primary_key=True)
 }}}
 Then remove the field and makemigrations
 {{{#!python
 class MySimpleModel(models.Model):
 pass
 }}}
 This prompts you to supply a default because

 {{{
 It is impossible to add a non-nullable field 'id' to mysimplemodel without
 specifying a default.
 }}}
 If you supply a default, you get a migration like this:

 {{{#!python
 from django.db import migrations, models


 class Migration(migrations.Migration):

 dependencies = [
 ('app3', '0001_initial'),
 ]

 operations = [
 migrations.RemoveField(
 model_name='mysimplemodel',
 name='some_pk',
 ),
 migrations.AddField(
 model_name='mysimplemodel',
 name='id',
 field=models.BigAutoField(auto_created=True, default=1,
 primary_key=True, serialize=False, verbose_name='ID'),
 preserve_default=False,
 ),
 ]
 }}}
 This crashes when you migrate with:
 {{{
 django.db.utils.OperationalError: near ")": syntax error
 }}}

 But if you remove the provided default from the migration and switch the
 order so that the field is added before the previous primary_key field is
 removed, the migration can be applied.


 This is very similar to #22997 and certainly related (they didn't remove
 the field but instead altered the field to no longer be a primary_key in
 that ticket).
 I am not sure whether to class this as a duplicate and require a fix as
 part of #22997 - happy to hear opinions here.
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f2ee72eba-ad63b6e2-a68d-4e45-a6b0-822d487acf71-00%40eu-central-1.amazonses.com.