coleifer / peewee

a small, expressive orm -- supports postgresql, mysql, sqlite and cockroachdb
http://docs.peewee-orm.com/
MIT License
11.17k stars 1.37k forks source link

Integer primary keys are expected to become AUTO_INCREMENT? #185

Closed moraes closed 11 years ago

moraes commented 11 years ago

For the snippet:

class foo(peewee.Model):
    id = peewee.IntegerField(primary_key=True)

db.compiler().create_table(foo, False)

The SQL generated for a MySQL database was:

CREATE TABLE `foo` (`id` INTEGER NOT NULL PRIMARY KEY)

Should I expect AUTO_INCREMENT to be added to id? I may have misunderstood the docs.

moraes commented 11 years ago

I must use PrimaryKeyField. Dooh. Sorry for being so stupid.