migration alter table laravel code example

Example 1: add column in laravel migration

php artisan make:migration add_paid_to_users_table --table=users

Example 2: laravel change column

Schema::table('users', function (Blueprint $table) {
    $table->string('name', 50)->nullable()->change();
});

Example 3: how to change existing migration laravel

php artisan make:migration update_user_guide_in_product_translations_table

Example 4: laravel migration

php artisan migrate

Example 5: laravel migration

php artisan make:migration create_users_table

Example 6: drop column migration laravel

Class RemoveCommentViewCount extends Migration
  {
      public function up()
      {
          Schema::table('articles', function($table) {
             $table->dropColumn('comment_count');
             $table->dropColumn('view_count');
          });
      }

      public function down()
      {
          Schema::table('articles', function($table) {
             $table->integer('comment_count');
             $table->integer('view_count');
          });
      }
  }

Tags:

Php Example