2017-03-04 137 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

是相同的消息 –