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

Screenshot 2025-02-20 at 5 25 31โ€ฏPM

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

Run directly without installation:

uvx open-webui-postgres-migration

Manual Installation

  1. Clone the repository:

    git clone https://github.com/taylorwilsdon/open-webui-postgres-migration.git
    cd open-webui-postgres-migration
    
  2. Set up environment:

    python -m venv venv
    source venv/bin/activate  # Windows: venv\Scripts\activate
    pip install -r requirements.txt
    
  3. Run the migration:

    python migrate.py
    

๐Ÿ“ Best Practices

  1. Before Migration:

    • Backup your SQLite database
    • CRITICAL: Set up PostgreSQL database and tables FIRST
      • Set the DATABASE_URL environment variable: DATABASE_URL="postgresql://user:password@host:port/dbname"
      • export DATABASE_URL="postgresql://user:password@host:port/dbname" for macOS / Linux
      • set DATABASE_URL="postgresql://user:password@host:port/dbname" for windows
      • Start Open WebUI with the PostgreSQL DATABASE_URL configured to create the database tables
      • Stop Open WebUI after confirming tables are created
      • The migration script will verify this step was completed before proceeding
    • Verify PostgreSQL server access from host running script
    • Check available disk space
  2. During Migration:

    • Don't interrupt the process
    • Monitor system resources
    • Keep network connection stable
  3. 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:

IssueSolution
Connection FailedCheck PostgreSQL credentials and firewall settings
Permission DeniedVerify PostgreSQL user privileges
Memory ErrorsReduce batch size in configuration
Encoding IssuesEnsure proper database character encoding
Failed Foreign Key Check for chat_file or knowledge_fileThe 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:

  1. Check the troubleshooting section above
  2. Search existing GitHub issues
  3. Create a new issue with:
    • Error messages
    • Database versions
    • System information