2017-12-06 12 views
0

Laravel 5.5를 사용하고 있는데 users이라는 기존 테이블에 추가 열을 추가하고 싶습니다.어떻게 데이터를 잃지 않고 기존 테이블에 여분의 열을 추가 할 수 있습니까?

php artisan migrate은 추가 열을 추가하지 않습니다.

1) 테이블이 비어 있지 않으므로 가능합니까?

2) 아래의 코드 블록이 작동하지 않는 이유는 무엇입니까? php artisan make:migration update_users_column --table=users 파일을 실행하여

이 만들어집니다 :

use Illuminate\Support\Facades\Schema; 
use Illuminate\Database\Schema\Blueprint; 
use Illuminate\Database\Migrations\Migration; 

class UpdateUsersColumn extends Migration 
{ 
    /** 
    * Run the migrations. 
    * 
    * @return void 
    */ 
    public function up() 
    { 
     Schema::table('users', function (Blueprint $table) { 
      $table->boolean('email_sent_to_user', true); 
     }); 
    } 

    /** 
    * Reverse the migrations. 
    * 
    * @return void 
    */ 
    public function down() 
    { 
//  Schema::table('users', function (Blueprint $table) { 
//   // 
//  }); 
    } 
} 

migrations 테이블이 업데이트됩니다 php artisan migrate를 실행 한 후하지만 users 테이블이 업데이트되지 않습니다.

+0

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

+0

@JunaidMasood 나는 이미 다른 게시물을 검색하고 보았습니다. 위의 코드가 작동하지 않는 이유를 이해할 수 없기 때문에 질문을 게시했습니다. –

+0

마이그레이션 테이블에이 마이그레이션이 있습니까? – fico7489

답변

1

코드 블록이 정상적으로 작동합니다. 문제는 내 로컬 컴퓨터에서 서버로 파일을 전송하는 절차 (올바른 권한이 아니 어서 파일을 편집 한 후에 실제로 업로드하지 않음) 때문이었습니다.