나는 articles
테이블 Schema
는 다음과 같이 정의되는 블로그했습니다 :5.2
public function up()
{
Schema::create('articles', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->string('title');
$table->string('thumb')->nullable();
$table->text('excerpt');
$table->text('body');
$table->string('slug')->unique();
$table->integer('comment_count')->unsigned()->default(0);
$table->integer('view_count')->unsigned()->default(0);
$table->timestamps();
$table->softDeletes();
}
public function down()
{
Schema::drop('articles');
}
내가 테이블
에서 기존 데이터를 손실없이 열comment_count
및
view_count
을 드롭 할을
은이 같은 새로운 마이그레이션 정의 :
class RemoveCommentViewCount extends Migration
{
public function up()
{
//nothing here
}
public function down()
{
Schema::table('articles', function($table) {
$table->dropColumn('comment_count');
$table->dropColumn('view_count');
});
}
}
을 나는 php artisan migrate
했다. 이주는 성공적 이었지만 두 컬럼은 h 제되지 않았습니다.
내가 뭘 잘못하고 있니? 테이블의 기존 데이터를 손실하지 않고 해당 열을 삭제하려면 어떻게해야합니까?
@ Sangar82에 의해 지적 되었 듯이, 나는'php artisan migrate'를 실행할 때 트리거되는'up()'메소드입니다. 'down()'메소드는 아래에 설명 된 것처럼'migrate : refresh' 또는'rollback'을 할 경우에 트리거됩니다. – daneczech