• Environment:Laravel 8
  • Need to useLaravelDatabase migration function, because I am an obsessive-compulsive Virgo so like their own named files such as:

  • However, an error was reported during migration:

  • After several rounds of trying to find outLaravelFor the migration fileFilename formatThere is fixed parsing, so when I write the filename exactly as it is written, it works fine

  • Of course, the class name must also be consistent:

  • The point of the joke is:There is no mention in the documentation of a mandatory file-name naming styleSo today record this small pit
  • Seems to be another pothole or shortcoming of the framework: the table structureYou can't integrate continuouslyIf, for example, I need to add fields to a table today, but it has already been migrated, then it willThere is no way to run the same migration file again. A new migration file must be createdOf course, I understand that this is for easy rollback, but my requirement is to keep adding fields for new functions, so I don’t need to rollbackThe solutionYou empty it every timemigrationsThis table, because this table controls whether the same migration file can be run over and over again, looks like this:
Trait Trait_Migrate {/** * @desc * @return Void */ static public function CI_Table_Structure() : DB::table('migrations') -> truncate(); Artisan::call('migrate --force --path=/database/migrations/'. SELF::$CI_File); }}
  • Generally speaking, it will be smooth sailing to follow the rules of the framework document completely, but it is very normal to encounter the situation that the default function of the framework cannot meet the requirements when doing a project