2017-01-12 125 views
0

遷移在Laravel 5.3的樞軸轉移後生成異常。在Laravel 5.3的樞軸轉移之後遷移不起作用

schema1 : software_houses 
schema2 : skill_domains 

我所產生的命令make:migration:pivot skill_domains software_houses

並通過的名稱skill_domain_software_house

創建的遷移,但是當我執行PHP人員遷移

發生以下錯誤:

[Symfony\Component\Debug\Exception\FatalThrowableError]  
Class 'CreateSkillDomainSoftwareHousePivotTable' not found 
遷移::轉動命令

<?php 

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

class CreateSkill_domainSoftware_housePivotTable extends Migration 
{ 
    /** 
    * Run the migrations. 
    * 
    * @return void 
    */ 
    public function up() 
    { 
     Schema::create('skill_domain_software_house', function (Blueprint $table) { 
      $table->integer('skill_domain_id')->unsigned()->index(); 
      $table->foreign('skill_domain_id')->references('id')->on('skill_domains')->onDelete('cascade'); 
      $table->integer('software_house_id')->unsigned()->index(); 
      $table->foreign('software_house_id')->references('id')->on('software_houses')->onDelete('cascade'); 
      $table->primary(['skill_domain_id', 'software_house_id']); 
     }); 
    } 

    /** 
    * Reverse the migrations. 
    * 
    * @return void 
    */ 
    public function down() 
    { 
     Schema::drop('skill_domain_software_house'); 
    } 
} 
:運行後化妝創建

See this Image

SKILL域

<?php 

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

class CreateSkillDomainsTable extends Migration 
{ 
    /** 
    * Run the migrations. 
    * 
    * @return void 
    */ 
    public function up() 
    { 

     Schema::create('skill_domains', function (Blueprint $table) { 
      $table->increments('id'); 
      $table->string('name')->unique(); 
      $table->timestamps(); 
     }); 


    } 

    /** 
    * Reverse the migrations. 
    * 
    * @return void 
    */ 
    public function down() 
    { 
     Schema::dropIfExists('skill_domains'); 
    } 
} 

Software House的

<?php 

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

class CreateSoftwareHousesTable extends Migration 
{ 
    /** 
    * Run the migrations. 
    * 
    * @return void 
    */ 
    public function up() 
    { 
     Schema::create('software_houses', function (Blueprint $table) { 
      $table->increments('id'); 
      $table->string('name',100)->unique(); 
      $table->string('desc',500); 
      $table->string('url',100); 
      $table->string('rating')->default('3'); 
      $table->string('logo')->nullable(); 
      $table->string('city')->nullable(); 

      $table->timestamps(); 
     }); 
    } 

    /** 
    * Reverse the migrations. 
    * 
    * @return void 
    */ 
    public function down() 
    { 
     Schema::dropIfExists('software_houses'); 
    } 
} 

透視表

+0

是什麼你的'skill_domain_software_house'遷移'class'名字? –

+0

SkillDomain_SoftwareHouse – user1809029

+0

在遷移之前創建模型有沒有關係? – user1809029

回答

0

嘗試用下面的類名行: class SkillDomainsSoftwareHouses extends Migration

確保文件名應該是匹配的類名Documentation

UPDATE
我想你應該試試這個:

首先從遷移除去上述software_houses,skill_domains文件夾也遷移表中您的數據庫中刪除,然後按照以下步驟進行:

1) php artisan make:migration skilldomain 
2) php artisan make:migration softwarehouses 
3) php artisan make:migration:pivot skilldomains softwarehouses 
4) php artisan migrate 
+0

你可以提供一些細節。 當我使用PHP 工匠製作:遷移:支點skill_domains software_houses 爲Laravel使用默認的命名約定 – user1809029

+0

文檔所擁有的一切,你想要什麼更多的東西可以去錯了嗎?順便說一句,顯示您的移植代碼。 –

+0

@ user1809029:將您的代碼放入您的問題部分。 –