dozpox8752 2015-10-20 22:33
浏览 74
已采纳

Laravel - [PDOException] SQLSTATE [42S02]:未找到基表或视图:1146表'ip.priorities'不存在

Hello im trying to migrate a table named ideas_roles_users with Laravel 5.1 but im getting the error

[PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ip.priorities' doesn't exist.

I'm really new with Laravel, hope anyone can help me. As you see im trying to make a table many to many and the error becomes from class CreateIdeasRolesUsersTable. Thank you.

<?

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');
    }
}

My class for Ideas

<?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');
    }
}

my class for users

<?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');
    }
}

My class for Roles is:

<?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');
    }
}
  • 写回答

2条回答 默认 最新

  • dongmi4035 2015-10-21 01:49
    关注

    Found the error. The problem it was that I had 'Schema::table('priorities', function($table)' and not 'Schema::table('ideas_roles_users', function($table)' because my table name is 'ideas_roles_users'. My bad. Thank you

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大