id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc
205,add_column fails for unique ForeignKey or OneToOneField,john.firebaugh@…,andrew,"{{{
    def test_add_unique_fk(self):
        """"""
        Test adding a ForeignKey with unique=True or a OneToOneField
        """"""
        db.create_table(""test_add_unique_fk"", [
            ('spam', models.BooleanField(default=False))
        ])
        db.start_transaction()
        
        db.add_column(""test_add_unique_fk"", ""mock1"", models.ForeignKey(db.mock_model('Mock', 'mock'), null=True, unique=True))
        db.add_column(""test_add_unique_fk"", ""mock2"", models.OneToOneField(db.mock_model('Mock', 'mock'), null=True))
        
        db.rollback_transaction()
        db.delete_table(""test_add_unique_fk"")

}}}

With a sqlite database, this produces:

{{{
OperationalError: table test_add_unique_fk has no column named mock1
}}}

when trying to create a unique index on column 'mock1'. It should instead be creating the unique index on column 'mock1_id'.",defect,closed,major,0.6,databaseapi,0.6-pre,fixed,,
