Skip to main content

Migrate Open WebUI from SQLite to PostgreSQL

Project description

Migrate tool for OpenWebUI SQLite

Migrate from using SQLite database in Open WebUI to use Postgres.

Inspiration from: https://github.com/taylorwilsdon/open-webui-postgres-migration, one of the big differences is that the migration require no input, with environment variables set, you just run the script, no input.

This so you can automate the process, instead of manual input.

Install

You can copy the script to you environment and run it, or you could install it:

pip install open-webui-sqlite-migration

Configuration

Before anything else, backup you SQLite database and keep it in a safe place.

Needed environment variables:

  • SQLITE_DB_PATH - exact path to your open webui db, like: /app/backend/data/webui.db.
  • MIGRATE_DATABASE_URL - normally the same you should use for DATABASE_URL, like postgresql://user:pass@postgres:5432/openwebui

Also you need to start Open WebUI with DATABASE_URL, so needed tables are created. After that, you remove that variable so you go back to use SQLite. When using SQLite, you run the migration script, then you stop Open WebUI, and then again set DATABASE_URL. If everything now runs smoothly, you can remove the SQLite database. Keep a backup of the database until you are really sure that all things are working as they should.

Migration

  • Again - make sure you backup your SQLite database, before doing anything.
  • Start Open WebUI with SQLite if it's not running (info logs should say: Context impl SQLiteImpl).
  • Stop Open WebUI.
  • Start Open WebUI with DATABASE_URL set. Needed tables should be created.
  • Stop Open WebUI.
  • Remove ENV variable DATABASE_URL, start Open WebUI.
  • Run open-webui-migrate-sqlite --dry-run
  • Check output, if what is you expected, go to next step.
  • Have you really done a backup of your SQLite database?
  • Run open-webui-migrate-sqlite
  • If all succeeds, restart Open WebUI with DATABASE_URL set.
  • You should now be running Open WebUI with Postgres (if you have info logs from Open WebUI, you should see Context impl PostgresqlImpl).

Development

Poetry is used.

poetry install

Release:

Make sure to change version, then:

poetry build
poetry publish

License

MIT Copyright (c) Digitalist Open Cloud.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

open_webui_sqlite_migration-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

open_webui_sqlite_migration-0.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file open_webui_sqlite_migration-0.1.1.tar.gz.

File metadata

  • Download URL: open_webui_sqlite_migration-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.4 Darwin/23.6.0

File hashes

Hashes for open_webui_sqlite_migration-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7eb58f074de82f895433f303f60426ac5b79d6e49cdc81beaa9f5be36ac29b8a
MD5 aa41d42147858f198feb2b9299d15cce
BLAKE2b-256 9c5a2de6167adb3fb7dc9d9d958c4b0d3b89d3ba36f816d83ab270ca2def8946

See more details on using hashes here.

File details

Details for the file open_webui_sqlite_migration-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for open_webui_sqlite_migration-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d2d5d0ff768822701b2c82261f7e034da6f92cd95d3dc25b3a742da14ba00a17
MD5 afa723859ecd22b5209343aa7619daba
BLAKE2b-256 2713162f8a33d8444a226b09cb5a050e8d13686f65aea00a49ed3306ba70a358

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page