2017-03-04 135 views
0

我有一個遷移表拒絕遷移表進行註冊..Laravel表拒絕被登記在遷移表和rollbacked或遷移

2014_10_12_000000_create_users_table 1 
2014_10_12_100000_create_password_resets_table 1 
2016_03_21_010421_create_orders_table 1 
2016_03_21_010549_create_types_table 1 
2016_03_21_010722_create_materials_table 1 
2016_03_21_010814_create_ratings_table 1 
2016_03_21_011205_create_costs_table 1 
2016_03_21_012114_create_locations_table 1 
2016_06_02_181122_create_assignments_table 1 
2016_06_25_001455_create_bills_table 1 
2016_07_26_195012_create_roles_table 1 
2016_08_06_205440_create_permissions_table 1 
2016_08_11_013917_create_material_order_table 1 

文件:2017_03_04_201351_create_permission_role_table.php

<?php 

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

class CreatePermissionRoleTable extends Migration 
{ 
    /** 
    * Run the migrations. 
    * 
    * @return void 
    */ 
    public function up() 
    { 
     /** 
     * Run the migrations. 
     * 
     * @return void 
     */ 
     Schema::create('permission_role', function (Blueprint $table) { 
      $table->integer('permission_id')->unsigned()->index(); 
      $table->integer('role_id')->unsigned()->index(); 

      $table->foreign('permission_id') 
       ->references('id') 
       ->on('permissions') 
       ->onDelete('cascade'); 

      $table->foreign('role_id') 
       ->references('id') 
       ->on('roles') 
       ->onDelete('cascade'); 

      $table->primary(['permission_id', 'role_id']); 
     }); 
    } 

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

這是遷移..

我試過composer dump也沒有出現..

它拒絕遷移..

我手動刪除,但有在migrate:refreshmigrate同樣的錯誤rollback後。

最後就是錯誤:

[Illuminate\Database\QueryException] 
    SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'permission_role' already exists (SQL: create table `permission_role` (`permission_id` in 
    t unsigned not null, `role_id` int unsigned not null) default character set utf8 collate utf8_unicode_ci) 

    [PDOException] 
    SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'permission_role' already exists 

表信息:innoDB

GitHub庫:鏈接

https://github.com/lifesound/fixgate

+0

這是'作曲家轉儲autoload'不'作曲家dump' –

+0

它的工作原理相同 –

+0

第一時間知道,你可以嘗試手動刪除所有的表,然後再試一次。 –

回答

0

我通過在權限表改變id column來代替(ENUM)(增量)。雖然這是我不想要的東西, 所以我必須枚舉添加到其他列找到了解決辦法..

在這種情況下,我從錯誤..瞭解到,2天瘦測試:

  1. 要確保你的表順序。關係表應該在 父表之後。

  2. 作曲者轉儲時更改任何文件名,刪除或添加。

  3. 關係列應該是無符號和索引。

  4. 使用migrate:reset刪除所有的遷移。然後再遷移。

  5. 如果更改了數據庫配置,請不要忘記清除配置。

  6. 確保您的表是innoDB。

0

您已經表permission_role,現在你的遷移表不能用你的數據庫一致。

如果你知道該怎麼做,你可以手動編輯的遷移表,恢復之後在遷移

你丟棄的文件並運行「作曲家轉儲自動加載」也許最好的方法就是手動刪除所有表(包括遷移表)並重新運行遷移。如果你可以放下所有的桌子。

+0

我做了所有的那 –

+0

和消息總是一樣的嗎? – dparoli

+0

是相同的消息 –