Database Migration Overview
Homarr supports three database types:SQLite
better-sqlite3Best for:
- Single-user instances
- Low traffic
- Simple setup
MySQL
mysql2Best for:
- Multi-user environments
- Higher traffic
- Shared hosting
PostgreSQL
node-postgresBest for:
- Enterprise deployments
- Advanced features
- High concurrency
- Scaling from SQLite to a more robust database
- Moving to a managed database service
- Consolidating with existing database infrastructure
- Performance optimization
Pre-Migration Checklist
Before starting a migration:Backup Everything
Create a complete backup of your current system:
- Database backup
- Configuration files (
.env,docker-compose.yml) - Data directory
Document Current Configuration
Record your current setup:
- Database type and version
- Homarr version
- Environment variables
- Custom configurations
Test in Development
If possible, test the migration process in a development environment first to identify potential issues.
Migrating Between Database Types
Homarr uses Drizzle ORM for database management, which handles schema differences between database types automatically.Migration Strategy
The recommended approach is to:- Export data from the old database
- Set up the new database
- Run migrations on the new database
- Import data into the new database
Direct database-to-database migration tools (like
pg_dump | mysql) won’t work due to schema differences. You’ll need to export and import data through Homarr or use database-specific tools.SQLite to MySQL/PostgreSQL
Set Up New Database
Install and configure your target database (MySQL or PostgreSQL).MySQL Example:PostgreSQL Example:
Update Homarr Configuration
Modify your For PostgreSQL:
.env file to point to the new database:For MySQL:Run Migrations
Start Homarr to run automatic migrations on the new database:You should see messages like:
Migrate Data
Currently, Homarr doesn’t include a built-in tool for data migration between database types. You have two options:Option A: Manual Recreation (Small Instances)
- Manually recreate boards, widgets, and settings in the new instance
- Use this for small configurations
- Export data from SQLite to JSON
- Write a script to import JSON into the new database
- See the migration script examples below
Migration Script Example
For advanced users, here’s an example of exporting data from SQLite:MySQL to PostgreSQL (or vice versa)
The process is similar to SQLite migration:- Backup current database
- Set up new database
- Update
.envwith new connection details - Run migrations
- Migrate data using export/import or custom scripts
Upgrading Homarr Versions
Homarr uses semantic versioning:MAJOR.MINOR.PATCH (e.g., 0.15.3)
Upgrade Types
Patch Upgrades (0.15.2 → 0.15.3)
Patch Upgrades (0.15.2 → 0.15.3)
Risk Level: LowPatch releases contain:
- Bug fixes
- Security patches
- Minor improvements
Minor Upgrades (0.14.x → 0.15.x)
Minor Upgrades (0.14.x → 0.15.x)
Risk Level: MediumMinor releases may contain:
- New features
- Database schema changes
- Deprecated features
- Performance improvements
Major Upgrades (0.x.x → 1.x.x)
Major Upgrades (0.x.x → 1.x.x)
Risk Level: HighMajor releases may contain:
- Breaking changes
- Significant architecture changes
- Removed features
- Major database schema changes
Standard Upgrade Procedure
Check Release Notes
Review the changelog for:
- Breaking changes
- Migration instructions
- New features
- Known issues
Rolling Back an Upgrade
If the upgrade fails:Handling Database Migrations
Automatic Migrations
Homarr automatically runs database migrations on startup using Drizzle ORM. Migration Process:- Homarr starts
- Checks current database schema version
- Applies pending migrations in order
- Seeds default data if needed
- Runs custom migrations
Manual Migration Execution
For advanced scenarios, you can run migrations manually: SQLite:Custom Migrations
Homarr includes custom migrations for complex data transformations. These are located inpackages/db/migrations/custom/.
Example custom migrations:
0000_release_widget_provider_to_options.ts- Migrates release widget settings0001_opnsense_credentials.ts- Updates OPNsense integration format0002_app_widget_show_description_tooltip_to_display_mode.ts- Updates app widget settings
Handling Breaking Changes
Breaking changes are documented in release notes. Common types include:Configuration Changes
Example: Environment Variable Renamed Old:.env file with the new variable name.
Widget Configuration Changes
Some updates change how widgets store their configuration. Example: Display Mode Migration The custom migration0002_app_widget_show_description_tooltip_to_display_mode.ts automatically converts:
API Changes
If you use Homarr’s tRPC API, breaking changes may affect your integrations. Migration: Review the API changelog and update your API calls accordingly.Removed Features
Occasionally, features may be removed or replaced. Migration:- Check release notes for alternatives
- Update your configuration to use replacement features
- Remove references to deprecated features
Migration Best Practices
Test First
- Always test migrations in a development environment
- Verify all features work after migration
- Document any issues encountered
- Plan for rollback if needed
Backup Everything
- Full database backup before migration
- Configuration file backups
- Test restoration before proceeding
- Keep multiple backup versions
Version Control
- Track configuration changes in git
- Document migration steps
- Keep notes on issues and resolutions
- Share knowledge with your team
Gradual Rollout
- Upgrade patch versions regularly
- Don’t skip multiple minor versions
- Read all intermediate release notes
- Plan major upgrades carefully
Troubleshooting Migrations
Migration fails with 'column already exists'
Migration fails with 'column already exists'
Cause: Database schema is out of sync with expected state.Solution:
- Check if you skipped versions
- Review database schema manually
- Restore from backup and re-run migration
- Contact support if issue persists
Data missing after migration
Data missing after migration
Cause: Migration script may have data transformation issues.Solution:
- Stop Homarr immediately
- Restore from backup
- Check migration logs for errors
- Report issue on GitHub with logs
Performance issues after migration
Performance issues after migration
Cause: Database indexes may need rebuilding.Solution:
Integration secrets not working after migration
Integration secrets not working after migration
Cause:
SECRET_ENCRYPTION_KEY changed or is missing.Solution:- Verify
SECRET_ENCRYPTION_KEYin.envmatches original - If key was lost, you’ll need to reconfigure integrations
- Integration secrets are encrypted and can’t be recovered without the original key
Version-Specific Migration Notes
Upgrading to 0.15.x
- New board layout system with sections
- Widget configuration format updated
- Custom migrations handle most conversions automatically
- Review widget settings after upgrade
Upgrading to 0.14.x
- Introduction of integration permissions system
- Group-based access control
- May require reassigning user permissions
Always check the specific release notes for the version you’re upgrading to. Version-specific instructions may override general guidance.
Next Steps
Backup Guide
Learn comprehensive backup strategies
Database Configuration
Configure database connections and settings
Troubleshooting
Get help with migration issues
Release Notes
View all version releases and changelogs
