user681365
user681365

Reputation: 353

Laravel Migration Remove a table

I have a table previously created with laravel migrations

Now I realise that I don't need that table.

Can I rollback only for that table (this is a migration file just for that table)?

The next time I will run migrate it is going to put it back in?

Or should I just create another migration to delete that table?

What is the recommended way?

Thanks

Upvotes: 1

Views: 1504

Answers (1)

Alexandre Butynski
Alexandre Butynski

Reputation: 6746

The answer depends on your working conditions.

Case 1 : you work alone or you have not already pushed your modifications

You just have to rollback the migration and then delete the migration file.

php artisan migrate:rollback
rm ./app/database/migrations/name_of_the_migration_file.php

Case 2 : you work in a team

In this case, one of your teammates could have already pulled and executed the migration. If you revert and delete it, he will not be able to delete the table easily.

Then you have to create an other migration to delete the table. This one should be the exact opposite of the previous one.

php artisan migrate::make revertTableCreation

Remember that the first goal of the migration system is to make team work and deployment easy by always keep consistent the code and the database.

Upvotes: 2

Related Questions