Ji Zhang
Ji Zhang

Reputation: 23

Schema migrations using peewee to create new models

I really like how lightweight and simple peewee is for ORM. But now I am trying to implement schema migtations in the database and I feel peewee might be a bit limited on this aspect. From what I understand in the documentation, peewee migrations support altering schema on the exisiting models such as add_not_null, add_column. I am wondering is there any operations from peewee that can be used for adding or deleting models. Or if there is any other libaries that can help on this? Thanks in advance.

Pointing to peewee operations or 3rd party libaries

Upvotes: 1

Views: 1031

Answers (1)

coleifer
coleifer

Reputation: 26235

Peewee itself has facilities for creating and dropping tables:

class MyModel(Model):
    ...

# Create tables
database.create_tables([MyModel, OtherModel, ...])

# Drop tables
database.drop_tables([MyModel, OtherModel, ...])

http://docs.peewee-orm.com/en/latest/peewee/api.html#Database.create_tables

Upvotes: 0

Related Questions