Updating table scheme without affecting data in Laravel

前端 未结 1 1757
太阳男子
太阳男子 2021-02-02 02:04

I am new to Laravel from code igniter and I am LOVING THE FRAMEWORK! My life is so much easier now.

I have created a table with columns using php artisan and entered som

相关标签:
1条回答
  • 2021-02-02 02:32

    create new migration with artisan name it addColumnFestivalTable

    <?php
    
    use Illuminate\Database\Migrations\Migration;
    use Illuminate\Database\Schema\Blueprint;
    
    class addColumnFestivalTable extends Migration {
    
    public function up()
    {
        Schema::table('festivals', function($table)
        {
            $table->string('new_col_name');
         });
    
    }
    
    public function down()
    {
        Schema::table('festivals', function($table)
        {
           $table->dropColumn('new_col_name');
        });
    }
    
    }
    

    for more information read Laravel 5.4 doc

    0 讨论(0)
提交回复
热议问题