laravellaravel-5

Laravel Migration to change table name


I want to change my two table name in the Laravel, so do I have to manually change the table name or it can be possible through migration.


Solution

  • from the docs https://laravel.com/docs/master/migrations

    To change a table name, you can do this:

    use Illuminate\Support\Facades\Schema;
    
    Schema::rename($from, $to);
    

    You can use the drop or dropIfExists methods to remove an existing table:

    Schema::drop('users');
    
    Schema::dropIfExists('users');
    

    Just add that to a migration and it should work.