Metadata-Version: 2.4
Name: open-webui-postgres-migration
Version: 1.0.2
Summary: A robust, interactive tool for migrating Open WebUI databases from SQLite to PostgreSQL
Project-URL: Homepage, https://github.com/taylorwilsdon/open-webui-postgres-migration
Project-URL: Repository, https://github.com/taylorwilsdon/open-webui-postgres-migration
Project-URL: Issues, https://github.com/taylorwilsdon/open-webui-postgres-migration/issues
Author-email: Taylor Wilsdon <taylor@example.com>
License: MIT License
        
        Copyright (c) 2025 Taylor Wilsdon
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: database,migration,open-webui,postgresql,sqlite
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Classifier: Topic :: Database :: Database Engines/Servers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.8
Requires-Dist: markdown-it-py==3.0.0
Requires-Dist: mdurl==0.1.2
Requires-Dist: psycopg[binary]==3.2.3
Requires-Dist: pygments==2.19.1
Requires-Dist: rich==13.9.4
Requires-Dist: typing-extensions==4.12.2
Description-Content-Type: text/markdown

# 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
<img width="600" alt="Screenshot 2025-02-20 at 5 25 31 PM" src="https://github.com/user-attachments/assets/d3e9cb13-3aff-455a-9860-8b1d530f5b9d" />

## 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:
```bash
uvx open-webui-postgres-migration
```

### Manual Installation

1. **Clone the repository:**
   ```bash
   git clone https://github.com/taylorwilsdon/open-webui-postgres-migration.git
   cd open-webui-postgres-migration
   ```

2. **Set up environment:**
   ```bash
   python -m venv venv
   source venv/bin/activate  # Windows: venv\Scripts\activate
   pip install -r requirements.txt
   ```

3. **Run the migration:**
   ```bash
   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 |


## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](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
