![](/img/trans.png)
[英]SQLSTATE[42S02]: Base table or view not found: 1146 Table '***.indices' doesn't exist laravel
[英]Laravel - [PDOException] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ip.priorities' doesn't exist
您好,我尝试使用Laravel 5.1迁移名为ideas_roles_users
的表,但收到错误
[PDOException] SQLSTATE [42S02]:找不到基表或视图:1146表'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');
}
}
问题是你的代码: Schema::table('priorities', function($table)
它应该是。 Schema::create()
不是Schema::table()
因为你试图创建一个表。 Schema::table()
如果要修改表,通常使用Schema::table()
。
发现错误。 问题是我有'Schema::table('priorities', function($table)'
而不是'Schema::table('ideas_roles_users', function($table)'
因为我的表名是'ideas_roles_users'。我不好,谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.