Add Index generation, change primary key gen

Add Index generation, change primary key generation. With MySQL it works
perfectly