2016-09-08 26 views
0

私は非常に奇妙な問題があります。マイグレーションを移行しようとすると、エラーが表示されます。Laravelの移行でテーブルが見つかりません

[Illuminate\Database\QueryException]           
    SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cforum.ticket' d 
    oesn't exist (SQL: alter table `ticket` add `id` int unsigned not null auto 
    _increment primary key, add `title` varchar(255) not null, add `description 
    ` varchar(255) not null, add `user_id` int unsigned not null, add `subject_ 
    id` int unsigned not null, add `status_id` int unsigned not null) 

私はすでにサーバーを再起動しています。ここで間違っている可能性が何

<?php 

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

class CreateTicketTable extends Migration 
{ 
    /** 
    * Run the migrations. 
    * 
    * @return void 
    */ 
    public function up() 
    { 
     Schema::table('ticket', function (Blueprint $table) { 

      $table->increments('id'); 
      $table->string('title'); 
      $table->string('description'); 

      $table->integer('user_id')->unsigned(); 
      $table->foreign('user_id') 
       ->references('id')->on('user') 
       ->onDelete('cascade'); 

      $table->integer('subject_id')->unsigned(); 
      $table->foreign('subject_id') 
       ->references('id')->on('subject') 
       ->onDelete('cascade'); 

      $table->integer('status_id')->unsigned(); 
      $table->foreign('status_id') 
       ->references('id')->on('status') 
       ->onDelete('cascade'); 
     }); 
    } 

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

enter image description here

:これは、チケットの移行のですか?

答えて

1

変更:

Schema::create('ticket', function (Blueprint $table){ 

とあなたのコンソールでcomposer dump-autoloadを使用します。

Schema::table('ticket', function (Blueprint $table){ 

に。

+0

おかげのようなキーALTERステートメントをforeingから別の創造しよう)、それは=を役に立てば幸い! – Jamie

+0

@Jamie大丈夫です。それが喜んで=) –

1

はあなたがヒーローであること

public function up() 
    { 
     Schema::create('ticket', function (Blueprint $table) { 
      $table->increments('id'); 
      $table->string('title'); 
      $table->string('description'); 
      $table->integer('user_id')->unsigned(); 
      $table->integer('subject_id')->unsigned(); 
      $table->integer('status_id')->unsigned();  
     } 
     Schema::table('ticket', function (Blueprint $table) { 

      $table->foreign('user_id') 
       ->references('id')->on('user') 
       ->onDelete('cascade'); 

      $table->foreign('subject_id') 
       ->references('id')->on('subject') 
       ->onDelete('cascade'); 

      $table->foreign('status_id') 
       ->references('id')->on('status') 
       ->onDelete('cascade'); 
     }); 
    } 
関連する問題