Opened 10 years ago

Closed 10 years ago

#24058 closed Bug (duplicate)

Sequence is dropped from AutoIncrement field on postgre when changing verbose name

Reported by: hakib Owned by: nobody
Component: Uncategorized Version: 1.7
Severity: Normal Keywords: migration, postgre
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

After adding verbose_name to an id field with auto increment I started getting errors on null PK. Further investigation reviled that after applying migration the id column was altered in a way that caused the sequence to be dropped. As far as i can tell this is an issue only on postgre.

Altering the id field manually to associate the sequence solved the problem.

On my dev machine using sqlite this issue is not happening.

class MyModel(models.Model):
	id = models.AutoField(primary_key=True)
	name = models.TextField(null=False,blank=False)

./manage.py makemigrations app
./manage.py migrate app

class MyModel(models.Model):
	id = models.AutoField(primary_key=True, verbose_name='Identity')
	name = models.TextField(null=False,blank=False)

./manage.py makemigrations app
./manage.py migrate app

manage.py shell
o = MyModel.objects.create(name='Will fail on NN constraint')

Python 2.7, Django 1.7, Postgresql 9.2

Change History (1)

comment:1 by Tim Graham, 10 years ago

Resolution: duplicate
Status: newclosed
Summary: Sequance is dropped from AutoIncrement field on postgre when changing verbose nameSequence is dropped from AutoIncrement field on postgre when changing verbose name

Duplicate of #23581

Note: See TracTickets for help on using tickets.
Back to Top