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 25317 Altering a 1to1 field to FK on Postgres drops uniqueness but does not create index synotna nobody "Changing a OneToOneField to a ForeignKey does not trigger an index to be created by the migration {{{ migrations.AlterField( model_name='contracttwitchchannelrevenueadsbycountry', name='revenue_data', field=models.ForeignKey(to='twitchrevenue.TwitchRevenueDataAdsByCountry'), preserve_default=True, ), }}} SQL for the migration: {{{ ./manage.py sqlmigrate partners 0021 BEGIN; ALTER TABLE ""partners_contracttwitchchannelrevenueadsbycountry"" DROP CONSTRAINT ""a45496b32304e658c2a94795584a1889""; ALTER TABLE ""partners_contracttwitchchannelrevenueadsbycountry"" ADD CONSTRAINT ""D321aaa5509069df3ee6b51c0eb97103"" FOREIGN KEY (""revenue_data_id"") REFERENCES ""twitchrevenue_twitchrevenuedataadsbycountry"" (""id"") DEFERRABLE INITIALLY DEFERRED; COMMIT; }}} Also, explicitly stating db_index=True does not cause a new migration to be created" Bug closed Migrations 1.8 Normal fixed a@… Shai Berger Accepted 1 0 0 0 0 0