Pterodactyl uses Laravel’s migration system to manage database schema changes. This guide covers running, creating, and troubleshooting migrations.
What are Migrations?
Migrations are version control for your database schema. They allow you to:
- Define database structure changes in PHP code
- Roll back changes if needed
- Share schema changes across environments
- Track database version history
Running Migrations
Initial Installation
During first-time setup, run all migrations:
Flags:
--seed: Run database seeders after migrations
--force: Required in production (bypasses confirmation)
Updating Panel
When updating Pterodactyl, run migrations to apply schema changes:
Auto-Upgrade (v1.3.0+)
Pterodactyl v1.3.0+ includes self-upgrade functionality:
This automatically:
- Backs up the current installation
- Downloads the latest release
- Runs migrations with
--force and --seed
- Clears caches
Migration Status
Check which migrations have been run:
Output:
Common Migrations
Server State Management
2021_01_17_152623_add_generic_server_status_column
Added unified status column to replace multiple state columns:
Possible statuses:
installing
install_failed
reinstall_failed
suspended
restoring_backup
null (normal operation)
API Key Enhancements
2023_02_23_191004_add_expires_at_column_to_api_keys_table
Added expiration support for API keys:
2022_06_18_112822_track_api_key_usage_for_activity_events
Links activity logs to API keys:
Backup Features
2021_05_03_201016_add_support_for_locking_a_backup
Added backup locking to prevent deletion:
2020_12_26_184914_add_upload_id_column_to_backups_table
Added support for S3 multipart uploads:
Server Transfers
2020_04_04_131016_add_table_server_transfers
Created table for tracking server transfers:
Schedule Improvements
2021_01_13_013420_add_cron_month
Added month field to schedule cron:
2021_05_01_092523_add_only_run_when_server_online_option_to_schedules
Added conditional execution:
Creating Custom Migrations
Only create custom migrations if you’re developing Panel modifications. Do not modify core migrations.
Generate Migration
Migration Structure
Common Schema Operations
Add Column:
Modify Column:
Drop Column:
Add Index:
Drop Index:
Rollback Migrations
Rolling back migrations can cause data loss. Always backup your database first.
Rollback Last Batch
Rollback Specific Steps
Rollback All
Rollback and Re-run
Migration Best Practices
1. Always Backup First
2. Test in Development
Never run untested migrations in production:
3. Use Transactions
For complex migrations:
4. Handle Data Migration
When changing column types, migrate existing data:
Troubleshooting
”Nothing to migrate”
All migrations are already run. Check status:
“Syntax error or access violation”
Database user lacks required permissions:
“SQLSTATE[42S01]: Base table or view already exists”
Migration already partially applied. Options:
- Rollback and retry
- Manually mark as run:
“Class not found” errors
Clear autoload cache:
“Migration table not found”
Database not initialized. Run:
MySQL 8 Compatibility
If encountering errors with MySQL 8:
MariaDB Compatibility
Some migrations may fail on MariaDB < 10.5. Upgrade to 10.5+ or use MySQL 8.
Database Maintenance
Optimize Tables
Repair Tables
Check Table Status
Migration History
Key migration milestones:
- v1.11.0: Added activity logging tables
- v1.8.0: Changed egg format to PTDL_v2
- v1.6.0: Added server transfer support
- v1.3.0: Unified server status column
- v1.0.0: Complete database restructure
- v0.7.x: Legacy structure (pre-1.0)
Further Reading