id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 27338 Running an AlterField to change a CharField primary key to AutoField crashes. Tim Graham nobody "For example: change `id = models.CharField(max_length=20, primary_key=True)` to `id = models.AutoField(primary_key=True)`. It generates this operation: {{{ migrations.AlterField( model_name='foo', name='id', field=models.AutoField(primary_key=True, serialize=False), ), }}} Running it on PostgreSQL gives: `django.db.utils.ProgrammingError: operator class ""varchar_pattern_ops"" does not accept data type integer`. I'm not sure if this can be made to work sensibly. Is it possible to autopopulate the `AutoField`? I ran into this situation while investigating #27267." Cleanup/optimization closed Migrations dev Normal fixed Accepted 0 0 0 0 0 0