def test_foreign_key_index(): tc = TableCreator('awesome') tc.foreign_key('int', 'user_id', references='user.id', on_delete='cascade', on_update='cascade') tc.add_index(('user_id',), False) assert isinstance(tc.model.user_id, peewee.ForeignKeyField) assert tc.model._meta.indexes == [(('user_id',), False)]
def test_foreign_key(): tc = TableCreator('awesome') tc.foreign_key('int', 'user_id', references='user.id', on_delete='cascade', on_update='cascade') assert isinstance(tc.model.user_id, peewee.ForeignKeyField)
def test_foreign_key_index(): tc = TableCreator('awesome') tc.foreign_key('int', 'user_id', references='user.id', on_delete='cascade', on_update='cascade') tc.add_index(('user_id', ), False) assert isinstance(tc.model.user_id, peewee.ForeignKeyField) assert tc.model._meta.indexes == [(('user_id', ), False)]