This project uses Peewee ORM and peewee-migrate to manage database schema migrations.
---- Create and activate a virtual environment:
python -m venv env
env\Scripts\activate # Windows
# or
source env/bin/activate # macOS/Linux
- Install dependencies:
pip install peewee peewee-migrate
python -m db.py
After defining your models (e.g., in models.py
), generate a migration script:
python -m peewee_migrate create `MIGRATE_NAME` --database sqlite:///app.db --auto
python -m peewee_migrate migrate --database sqlite:///app.db
This applies all unapplied migrations to the database.
Action | Command |
---|---|
Rollback one step | python -m peewee_migrate rollback |
List migrations | python -m peewee_migrate list |
- Database file:
app.db
- Migration folder:
migrations/
- You do not need to manually create tables using
db.create_tables()
when using migrations.