I've recently included a package that has the same migration class name in a migration file:
class CreateCustomersTable extends Migration
Now I'm wondering if I can safely rename the class name of my own existing migration (that already ran). Will that create issues in the future? I've already renamed the table and updated that using protected $table
on the model so that's all fine, just wondering about the class name in the migration file.
CodePudding user response:
No, this should be no problem at all.
Laravel identifies the migrations from its filename, instead of its containing class(es). You can have a look at the migrations table of your database.
This is also the reason why a migration file consists of the current date.
CodePudding user response:
I think there is no problem if you keep 2 classes with same name while they are not at the same Namespace
but if you want to rename the migration then you have to take care of two things:
first rename the filename
open that migration file and rename the Class name also
Renaming the file :
change your filename from 2019_06_28_131130_create_organisations_table
to 2019_06_28_131130_create_organizations_table
or whatever name you want.
Open that migration file and Rename the class name in that file as per your new name:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
//change it from
//class CreateOrganisationsTable extends Migration {
//to
class CreateOrganizationsTable extends Migration {