Skip to main content

A robust, interactive tool for migrating Open WebUI databases from SQLite to PostgreSQL

Project description

Open WebUI PostgreSQL Migration Tool 🚀

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

Easy Installation with uvx (Recommended)

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:

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:

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

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_postgres_migration-1.0.7.tar.gz (46.3 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_postgres_migration-1.0.7-py3-none-any.whl (95.9 kB view details)

Uploaded Python 3

File details

Details for the file open_webui_postgres_migration-1.0.7.tar.gz.

File metadata

File hashes

Hashes for open_webui_postgres_migration-1.0.7.tar.gz
Algorithm Hash digest
SHA256 1f02981aec84d4ac0bdad1ad4d980958578f4822a72d66927f41747b3fa4f17c
MD5 dc46b529e17db18b1c13c492e9a9e294
BLAKE2b-256 c5df46774ef2c06f4bc0ea5be49a66045f7f5c664f07d55462c8ef0a4460bd7b

See more details on using hashes here.

File details

Details for the file open_webui_postgres_migration-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for open_webui_postgres_migration-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c7aa989e65dde97496214a463076544ae632b6355fa59db833c90f0960da962c
MD5 f7149380103ac77580d7fc4e4fcb7034
BLAKE2b-256 62f9e6e27efbd955f7f252399f34203c54cdb827036f2180c88f0d9cac792c09

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