open-webui/backend/apps/web/internal/migrations
Timothy J. Baek ca3108a54d refac
2024-05-24 20:29:13 -07:00
..
001_initial_schema.py fix 2024-04-27 19:44:36 -07:00
002_add_local_sharing.py feat: migrate db schema for local sharing 2024-04-02 08:58:03 -07:00
003_add_auth_api_key.py refac: api_key field moved to user 2024-04-02 09:23:55 -07:00
004_add_archived.py feat: archive chat 2024-04-20 17:03:39 -05:00
005_add_updated_at.py feat: add support for using postgres for the backend DB 2024-04-27 15:33:20 +01:00
006_migrate_timestamps_and_charfields.py feat: add support for using postgres for the backend DB 2024-04-27 15:33:20 +01:00
007_add_user_last_active_at.py fix 2024-04-27 20:06:07 -07:00
008_add_memory.py feat: memory backend 2024-05-19 08:00:07 -07:00
009_add_models.py fix 2024-05-23 22:59:11 -07:00
010_migrate_modelfiles_to_models.py refac 2024-05-24 20:29:13 -07:00
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.