First I rolled back 2 migrations by mistake, then I ran php artisan migrate
command and I got the following error:
[Illuminate\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'exercise1.categories' doesn't exist (SQL: select * from
categories
where parent_id
= 0)
[PDOException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'exercise1.categories' doesn't exist
Then I stopped Laravel. After that when I run the php artisan serve
command for starting Laravel I get the same error.
Here are 2 migrations which I've rolled back:
1.
class CreateCategoriesTable extends Migration
{
public function up()
{
Schema::create('categories',function (Blueprint $table){
$table->increments('id');
$table->string('name');
$table->text('parent_id');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('categories');
}
}
2.
class CreateArticlesTable extends Migration
{
public function up()
{
Schema::create('articles', function (Blueprint $table) {
$table->increments('id');
$table->string('title')->nullable(false);
$table->longText('article')->nullable(false);
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('articles');
}
}
Please help me to solve this frustrating problem. All answers are highly appreciated, thanks in advance.
categories
table in other migrations. I didn't add foreign key toparent_id
in latter migrations. – Mahammad Isgandarli Mar 01 '17 at 08:12