If you can't recover the migration file, you could recreate it and then roll it back or you could just use SQLpro and remove what you need to if all else fails.
Deleting a migration
Hello, i want to delete a migration file but when i did i cannot migrate:refresh again because it cannot find the deleted file, how can i properly do this?
But i want it to be gone, but how can i properly delete it? @ejdelmonico
@ejdelmonico he would have to remember the timestamp from the migration file if he were to recreate it.
Rule one of migration, never delete your migration files if you have migrated them.
You will have to manually go in and delete the table it created and remove the migration from the migration's table.
Here's what you can do.
- Look at your migrations table and find the migration you deleted
- create a new migration with the name of the deleted migration (add the timestamps from the migrations table
- run
php artisan migrate:rollback - delete the migration and continue
Alternatively you could:
- manually go into your database and delete every table (disable integrity checks) and migrate again
If you are on a production server with valuable data do not choose option #2
The timestamp is in the DB in the migrations table at the start of the migration name.
@Robinvm What system are you on? You can probably recover the deleted file.
@ejdelmonico i recoverd the files and putted them back in the folder, how can i delete the migration now? including the file
You can delete the file and the record with the same filename from the migrations table and it should not cause any troubles.
For future reference, rollback past the migration you want to delete, before deleting the migration. Just make sure that more recent migrations don't depend on the migration you're deleting.
php artisan migrate:rollback and then after you get the DB where you want it, you can delete the migration file again.
Tip: After deleting migration files you might need to do composer dump-autoload
it wont let me do that command @leber
Please or to participate in this conversation.