def test_index():
    tc = TableCreator('awesome')
    tc.column('char', 'fname')
    tc.column('char', 'lname')
    tc.add_index(('fname', 'lname'), unique=True)

    assert tc.model._meta.indexes == [(('fname', 'lname'), True)]
Example #2
0
def test_index():
    tc = TableCreator('awesome')
    tc.column('char', 'fname')
    tc.column('char', 'lname')
    tc.add_index(('fname', 'lname'), unique=True)

    assert tc.model._meta.indexes == [(('fname', 'lname'), True)]
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)]
Example #4
0
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)]