Open WebUI PostgreSQL Migration Tool ๐
April 28, 2026 ยท View on GitHub
A robust, interactive tool for migrating Open WebUI databases from SQLite to PostgreSQL. Designed for reliability and ease of use.
Preview
Migration Demo
https://github.com/user-attachments/assets/5ea8ed51-cc2d-49f0-9f1a-36e2f4e04f30
โจ Features
- ๐ฅ๏ธ Interactive command-line interface with clear prompts
- ๐ Comprehensive database integrity checking
- ๐ฆ Configurable batch processing for optimal performance
- โก Real-time progress visualization
- ๐ก๏ธ Robust error handling and recovery
- ๐ Unicode and special character support
- ๐ฏ Automatic table structure conversion
๐ Quick Start
Easy Installation with uvx (Recommended)
Run directly without installation:
uvx open-webui-postgres-migration
Manual Installation
-
Clone the repository:
git clone https://github.com/taylorwilsdon/open-webui-postgres-migration.git cd open-webui-postgres-migration -
Set up environment:
python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt -
Run the migration:
python migrate.py
๐ Best Practices
-
Before Migration:
- Backup your SQLite database
- CRITICAL: Set up PostgreSQL database and tables FIRST
- Set the
DATABASE_URLenvironment variable:DATABASE_URL="postgresql://user:password@host:port/dbname" export DATABASE_URL="postgresql://user:password@host:port/dbname"for macOS / Linuxset DATABASE_URL="postgresql://user:password@host:port/dbname"for windows- Start Open WebUI with the PostgreSQL
DATABASE_URLconfigured to create the database tables - Stop Open WebUI after confirming tables are created
- The migration script will verify this step was completed before proceeding
- Set the
- Verify PostgreSQL server access from host running script
- Check available disk space
-
During Migration:
- Don't interrupt the process
- Monitor system resources
- Keep network connection stable
-
After Migration:
- Verify data integrity
- Test application functionality
- Keep SQLite backup until verified
๐ง Configuration Options
During the migration, you'll be prompted to configure:
-
SQLite Database
- Path to your existing SQLite database
- Automatic validation and integrity checking
-
PostgreSQL Connection
- Host and port
- Database name
- Username and password
- Connection testing before proceeding
-
Performance Settings
- Batch size (100-5000 recommended)
- Automatic memory usage warnings
โ๏ธ System Requirements
- Python 3.8+
- PostgreSQL server (running and accessible)
- Sufficient disk space for both databases
- Network access to PostgreSQL server
๐ก๏ธ Safety Features
- โ Pre-migration database integrity verification
- โ Transaction-based processing
- โ Automatic error recovery
- โ Failed row tracking and reporting
- โ Progress preservation on interruption
๐จ Troubleshooting
Common issues and solutions:
| Issue | Solution |
|---|---|
| Connection Failed | Check PostgreSQL credentials and firewall settings |
| Permission Denied | Verify PostgreSQL user privileges |
| Memory Errors | Reduce batch size in configuration |
| Encoding Issues | Ensure proper database character encoding |
Failed Foreign Key Check for chat_file or knowledge_file | The migration skips orphaned attachment rows that reference deleted chats or knowledge bases and reports how many rows were skipped |
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ฌ Support
If you encounter issues:
- Check the troubleshooting section above
- Search existing GitHub issues
- Create a new issue with:
- Error messages
- Database versions
- System information