Migrate tool for Open WebUI - SQLite to Postgres
Migrate from using SQLite (default) in Open WebUI to use Postgres.
Inspiration from: https://github.com/taylorwilsdon/open-webui-postgres-migration, one of the big differences is that this migration require no input, configurable with environment variables, you just run the script, no input needed.
This so you can automate the whole process.
Version supported
As we are migrating tables in a specific order, the known Open WebUI version that this tools support is at this moment 0.8.12.
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 forDATABASE_URL, likepostgresql://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.
While you always should have a backup of your SQLite database before starting, the migration itself is done on a copy of the SQLite database, to avoid locking etc.
/tmp needs to be writeable during the migration.
Migration
- Make sure you backup your SQLite database, before doing anything.
- Set
SQLITE_DB_PATHandMIGRATE_DATABASE_URL - 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_URLset. 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_URLset. - You should now be running Open WebUI with Postgres (if you have info logs from Open WebUI, you should see
Context impl PostgresqlImpl).
Usage
# Run migration
open-webui-migrate-sqlite
# Dry run (preview without writing)
open-webui-migrate-sqlite --dry-run
# Show row counts in SQLite (before migration)
open-webui-migrate-sqlite --sqlite-counts
# Show row counts in PostgreSQL (after migration)
open-webui-migrate-sqlite --postgres-counts
# Validate migration (compare SQLite to PostgreSQL counts)
open-webui-migrate-sqlite --validate
Development
Poetry is used.
poetry install
Release:
Make sure to change version, then:
poetry build
poetry publish
Tests
export SQLITE_DB_PATH="/web.db"
export MIGRATE_DATABASE_URL=postgresql://user:pass@postgres:5432/openwebui
poetry run pytest
Coverage
poetry run pytest --cov
Linting
poetry run pylint $(git ls-files '*.py')
SBOM
Included in releases.
License
MIT
Copyright (c) Digitalist Open Cloud.
Metadata
Release files for open-webui-sqlite-migration 0.1.22
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| open_webui_sqlite_migration-0.1.22.tar.gz | 7.7 kB | Without provenance | Details for open_webui_sqlite_migration-0.1.22.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| open_webui_sqlite_migration-0.1.22-py3-none-any.whl | Python 3 | none | any | Details for open_webui_sqlite_migration-0.1.22-py3-none-any.whl |
Total release size: 16.4 kB
Release files / open_webui_sqlite_migration-0.1.22.tar.gz
| Download URL | open_webui_sqlite_migration-0.1.22.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb450006b47b6b279ee358a459aa035ea98fa9b25e7112cf2666dded0a03b3b2
|
|
BLAKE2b-256 checksum How to use checksums |
7e5bea86ef7df88888d8585d5157b2515164c1bfba4e459f926b24544df28843
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.13.4 Darwin/23.6.0
|
Release files / open_webui_sqlite_migration-0.1.22-py3-none-any.whl
| Download URL | open_webui_sqlite_migration-0.1.22-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
12730f7033f9ccd08f86c46a2c2b9d30cd14f3eab9faafd383f9879398775897
|
|
BLAKE2b-256 checksum How to use checksums |
c5885eec03ff56499048b6bad4b378d22b765950b6cfaef6cddc07b0ebc9d318
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.13.4 Darwin/23.6.0
|
Security for open-webui-sqlite-migration 0.1.22
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.