It sounds like your database tables were dropped and recreated during or after the upgrade, which would explain the missing data (and only the migrations table retaining data). This situation most commonly happens if a command like php artisan migrate:fresh or php artisan db:wipe was run, either directly, through a post-update script, or as part of an automated process (for example, some test suites or IDE integrations).
Here’s what might have happened and how to avoid it:
Possible Causes
-
Accidentally Running
migrate:freshor Similar- Sometimes developers run commands to ensure migrations are up-to-date, but
migrate:freshdrops all tables and re-runs all migrations, resulting in an empty database except for the migrations table.
- Sometimes developers run commands to ensure migrations are up-to-date, but
-
Test or Post-Install Scripts in
composer.json- Check if there are any
"post-update-cmd"or similar hooks in yourcomposer.jsonthat might run destructive database commands.
- Check if there are any
-
Environment Configuration Switched
- Ensure that your
.envpoints to your development database, not your production one, and that it didn’t temporarily point to a blank/testing database.
- Ensure that your
-
Database Testing (
php artisan test)- If you ran tests and your
phpunit.xmlis configured to use your development DB without a separateDB_CONNECTION, the testing process could have wiped your local DB.
- If you ran tests and your
How To Prevent This
- Never run destructive commands (
migrate:fresh,db:wipe) on production without a full, tested backup. - Always check your
.envbefore running migrations/commands post-upgrade. - Use a separate database for testing! Make sure your
.env.testingorphpunit.xmldoes not point to your development or production database. - Back up your database before any major upgrades (even on local).
- Review composer scripts in
composer.json:// Check for anything unexpected "scripts": { "post-update-cmd": [ // Any database commands here? If so, consider removing or making them safer! ] }
Recovery
Since this was your local database, hopefully, you have a backup or can repopulate the database with seed data. Unfortunately, without a backup, the data is likely unrecoverable after the fresh migration.
Summary
Upgrading Laravel does not delete your data. Laravel’s core upgrade (Composer update and dependency changes) will never drop or truncate tables. Only running migration-related Artisan commands like migrate:fresh, db:wipe, or automated scripts (explicitly or implicitly) will do this.
Before upgrading production:
- Take a full database backup.
- Test your upgrade locally and on staging, ensuring no unintended table drops.
- Avoid running unnecessary destructive Artisan commands.
Example Safe Update Process
# Backup your database (important!)
php artisan migrate # Runs only new migrations, keeps data
composer update # Updates dependencies
# Do NOT run migrate:fresh unless you are okay to lose all data!
If you need to run fresh migrations, always double-check that your .env uses the intended database.
If you need further help auditing your commands or configurations, post your composer scripts and a list of exactly what commands you ran, and I’ll help you spot the problem!