1

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

Ji Zhang
  • 23
  • 4

1 Answers1

0

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

coleifer
  • 24,887
  • 6
  • 60
  • 75
  • Thanks. But if I understand correctly it is not possible to add these operations to a migrator? Also wondering if there is an easy way to revert the migration operations in one migrator so we can roll back to the previous version of the schema. – Ji Zhang Mar 31 '22 at 14:01