Jun Siang Cheah f21c8626d6 refac: switch to meta and params, remove source 11 kuukautta sitten
..
001_initial_schema.py 48ed701960 fix 1 vuosi sitten
002_add_local_sharing.py e273a99153 feat: migrate db schema for local sharing 1 vuosi sitten
003_add_auth_api_key.py ba0523cd69 refac: api_key field moved to user 1 vuosi sitten
004_add_archived.py fbd520bf07 feat: archive chat 1 vuosi sitten
005_add_updated_at.py e91a49c455 feat: add support for using postgres for the backend DB 1 vuosi sitten
006_migrate_timestamps_and_charfields.py e91a49c455 feat: add support for using postgres for the backend DB 1 vuosi sitten
007_add_user_last_active_at.py 71a75bccf5 fix 1 vuosi sitten
008_add_memory.py 288d8a3e32 feat: memory backend 11 kuukautta sitten
009_add_models.py f21c8626d6 refac: switch to meta and params, remove source 11 kuukautta sitten
README.md 151055590d feat: add ability to run db migrations 1 vuosi sitten

README.md

Database Migrations

This directory contains all the database migrations for the web app. Migrations are done using the peewee-migrate library.

Migrations are automatically ran at app startup.

Creating a migration

Have you made a change to the schema of an existing model? You will need to create a migration file to ensure that existing databases are updated for backwards compatibility.

  1. Have a database file (webui.db) that has the old schema prior to any of your changes.
  2. Make your changes to the models.
  3. From the backend directory, run the following command:

    pw_migrate create --auto --auto-source apps.web.models --database sqlite:///${SQLITE_DB} --directory apps/web/internal/migrations ${MIGRATION_NAME}
    
    • $SQLITE_DB should be the path to the database file.
    • $MIGRATION_NAME should be a descriptive name for the migration.
  4. The migration file will be created in the apps/web/internal/migrations directory.