Make migration for existing table

If you make a migration for existing table, and you want Laravel to generate the Schema::table() for you, then add "_in_xxxxx_table" or "_to_xxxxx_table" at the end, or specify "--table" parameter. php artisan change_fields_products_table generates empty class

1class ChangeFieldsProductsTable extends Migration
2{
3 public function up()
4 {
5 //
6 }
7}

But add in_xxxxx_table php artisan make:migration change_fields_in_products_table and it generates class with Schema::table() pre-filled

1class ChangeFieldsProductsTable extends Migration
2{
3 public function up()
4 {
5 Schema::table('products', function (Blueprint $table) {
6 //
7 })
8 };
9}

Also you can specify --table parameter php artisan make:migration whatever_you_want --table=products

1class WhateverYouWant extends Migration
2{
3 public function up()
4 {
5 Schema::table('products', function (Blueprint $table) {
6 //
7 })
8 };
9}

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord