Jun Siang Cheah 4aab460905 Merge remote-tracking branch 'upstream/dev' into feat/oauth преди 10 месеца
..
001_initial_schema.py 1fce466253 refac: folder rename web -> webui преди 11 месеца
002_add_local_sharing.py 1fce466253 refac: folder rename web -> webui преди 11 месеца
003_add_auth_api_key.py 1fce466253 refac: folder rename web -> webui преди 11 месеца
004_add_archived.py 1fce466253 refac: folder rename web -> webui преди 11 месеца
005_add_updated_at.py 1fce466253 refac: folder rename web -> webui преди 11 месеца
006_migrate_timestamps_and_charfields.py 1fce466253 refac: folder rename web -> webui преди 11 месеца
007_add_user_last_active_at.py 1fce466253 refac: folder rename web -> webui преди 11 месеца
008_add_memory.py 1fce466253 refac: folder rename web -> webui преди 11 месеца
009_add_models.py 1fce466253 refac: folder rename web -> webui преди 11 месеца
010_migrate_modelfiles_to_models.py 1fce466253 refac: folder rename web -> webui преди 11 месеца
011_add_user_settings.py ccbafca74c feat: save user settings to db преди 11 месеца
012_add_tools.py 3a96e1f109 feat: tools backend преди 11 месеца
013_add_user_info.py 4b6b33b08b feat: user_location преди 10 месеца
013_add_user_oauth_sub.py 4ff17acc1b Merge remote-tracking branch 'upstream/dev' into feat/oauth преди 10 месеца
014_add_files.py 7c2a198370 feat: file db migration преди 10 месеца
015_add_functions.py 27f8afebab feat: function db migration преди 10 месеца
README.md 1fce466253 refac: folder rename web -> webui преди 11 месеца

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.webui.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.