2015-10-20 121 views
0

您好我試圖遷移名爲ideas_roles_users Laravel 5.1表,但即時獲取錯誤Laravel - [PDOException] SQLSTATE [42S02]:基表或視圖未找到:1146表'ip.priorities'不存在

[PDOException] SQLSTATE [42S02]:未找到基本表或視圖:1146 Table'ip.priorities'不存在。

我真的是新的Laravel,希望任何人都可以幫助我。正如你所看到的,我試圖製作一個桌子,多到很多,錯誤從CreateIdeasRolesUsersTable。謝謝。

<? 

class CreateIdeasRolesUsersTable extends Migration 

{ 
    public function up() 
    { 
Schema::create('ideas_roles_users', function (Blueprint $table) { 
      $table->integer('id_ideas')->unsigned(); 
      $table->integer('id_roles')->unsigned(); 
      $table->integer('id_users')->unsigned(); 

      $table->primary(['id_ideas', 'id_roles', 'id_users']); 


      $table->timestamps(); 

     }); 

     Schema::table('priorities', function($table) { 
      $table->foreign('id_ideas')->references('id')->on('ideas'); 
      $table->foreign('id_roles')->references('id')->on('roles'); 
      $table->foreign('id_users')->references('id')->on('users'); 
     }); 


    } 
    public function down() 
    { 
     Schema::drop('ideas_roles_users'); 
    } 
} 

我的想法

<?php 

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

class CreateIdeasTable extends Migration 
{ 
    /** 
    * Run the migrations. 
    * 
    * @return void 
    */ 
    public function up() 
    { 
     Schema::create('ideas', function (Blueprint $table) { 
      $table->increments('id'); 
      $table->string('nombre'); 
      $table->string('descripcion'); 
      $table->timestamps(); 
     }); 
    } 

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

我班類用戶

<?php 

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

class CreateUsersTable extends Migration 
{ 
    /** 
    * Run the migrations. 
    * 
    * @return void 
    */ 
    public function up() 
    { 
     Schema::create('users', function (Blueprint $table) { 
      $table->increments('id'); 
      $table->string('user'); 
      $table->string('nombre'); 
      $table->string('appellidoP'); 
      $table->string('appellidoM'); 
      $table->string('email')->unique(); 
      $table->string('password', 60); 
      $table->string('pais'); 
      $table->string('estado'); 
      $table->string('ciudad'); 
      $table->rememberToken(); 
      $table->timestamps(); 
     }); 
    } 

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

我類的角色是:

<?php 

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

class CreateRolesTable extends Migration 
{ 
    /** 
    * Run the migrations. 
    * 
    * @return void 
    */ 
    public function up() 
    { 
     Schema::create('roles', function (Blueprint $table) { 
      $table->increments('id'); 
      $table->string('nombre'); 
      $table->longText('descripcion'); 
      $table->timestamps(); 
     }); 
    } 

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

回答

0

發現錯誤。問題是我有'Schema::table('priorities', function($table)'而不是'Schema::table('ideas_roles_users', function($table)',因爲我的表名是'ideas_roles_users'。我的錯。謝謝

0

的問題是你的代碼:Schema::table('priorities', function($table)。因爲您正嘗試創建表格,所以它應該是Schema::create()而不是Schema::table()。如果要修改表格,通常使用Schema::table()

+0

你好,感謝您的時間回答。我發現錯誤,並不是「Schema :: table」它是我有'Schema ::表('優先級',函數($表)',而不是'Schema :: table('ideas_roles_users',function( $ table)',因爲我的表名是'ideas_roles_users'。再次感謝你。 –

相關問題