LARAVEL - Loss after running the MIGRATE command

Asked

Viewed 222 times

0

Monday I inserted a new migrate into a project, where a new table was created.

After running the commands in the local environment and everything works, I updated the git of the production server and ran PHP ARTISAN MIGRATE as usual.

It turns out that in one of my tables, most of the data disappeared (it was a table of accounts, with about 700 records).

The result of migrate in the shell was the expected one, appends the insertion of the new table and no error or information that something would have happened with the table "accounts".

Has anyone ever suffered from this mistake? Found a solution?

1 answer

0

Do you have the seeders set up and ready with the data that was in the table? If you just run migrate, it will only recreate the database. Some migration operations are destructive, which means they can cause you to lose data. To protect you from running these commands in your production database, you will be prompted to confirm before the commands are executed. Unless you used the --force flag or . env is not set to "Production".

To reverse the latest migration operation, you can use the rollback command. This command reverts the last "batch" of migrations, which can include multiple migration files:

php artisan migrate:rollback

Documentation - Migrations

Browser other questions tagged

You are not signed in. Login or sign up in order to post.