Laravel

Permasalahan mysql laravel: 

alter user 'root'@'localhost' identified with mysql_native_password by 'abc@123';


When u done with migration, but want to add column:

  1. Create a migration file using cli command:

    php artisan make:migration add_paid_to_users_table --table=users

  2. A file will be created in the migrations folder, open it in an editor.

  3. Add to the function up():

Schema::table('users', function (Blueprint $table) {
    // Create new column
    // You probably want to make the new column nullable
    $table->integer('paid')->nullable()->after('status');
}
  1. Add to the function down(), this will run in case migration fails for some reasons:

    $table->dropColumn('paid');

  2. Run migration using cli command:

    php artisan migrate

https://stackoverflow.com/questions/16791613/add-a-new-column-to-existing-table-in-a-migration





Comments