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