Laravel에 ClosureTable을 사용하고 있습니다. 마이그레이션에 문제가 있습니다. 외래 키가 생성 될 때 오류가 발생ClosureTable을 사용하여 Laravel4에서 이전 할 수 없습니다.
// Page_Closure 이주 스크립트
public function up()
{
Schema::table('page_closure', function(Blueprint $table)
{
$table->engine = 'InnoDB';
Schema::create('page_closure', function(Blueprint $t)
{
$t->increments('ctid');
$t->integer('ancestor', false, true);
$t->integer('descendant', false, true);
$t->integer('depth', false, true);
//problem after this line.
$t->foreign('ancestor')->references('id')->on('pages');
$t->foreign('descendant')->references('id')->on('pages');
});
});
}
:
이처럼 내 마이그레이션 스크립트 모습입니다. IDK 왜,하지만 내 마이 그 레이션 대기열 "페이지 폐쇄"에 따라 "페이지"스크립트 전에 먼저 실행됩니다. 다음 내부 Schema::create('page_closure', ...)
을 Schema::table('page_closure', ...)
이렇게함으로써
[Illuminate\Database\QueryException]
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'page_closure' already exists (SQL: create table `page_closure` (`ctid` int unsign
ed not null auto_increment primary key, `ancestor` int unsigned not null, `descendant` int unsigned not null, `depth` int unsigned not null) defa
ult character set utf8 collate utf8_unicode_ci)
안녕 Unnawut,이 마이그레이션 스크립트는 스캐 폴딩 이후에 생성되었습니다. "php artisan closuretable : make --entity = page"이 패키지는 https://github.com/franzose/ClosureTable 패키지를 사용했습니다. 따라서이 오류가있는 마이그레이션 스크립트를 생성하려면 스캐 폴드에 잘못된 것이 있어야합니다. – olleh
@olleh 그때 그들에게 버그를보고 싶을 것 같아요. 같은 테이블 이름의'Schema :: table()'과'Schema :: create()'를 서로 가지고있는 것은 당연한 것 같습니다. 나는'Schema :: table()'에 들어가는 것이 클로져 테이블이 아닌 여러분의 엔티티 테이블의 이름이어야한다고 생각한다. 어쩌면 당신은 그것을 바꿀 수 있습니다. – Unnawut