0

I came across the following error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'street-box.chanels' doesn't exist

So, after hours trying to find the erroor I gave up and did the following:

  • I made a backup of everything.
  • I "GIT" and created a new branch.
  • I deleted the database and created a new one fresh with a new name.
  • I declare the new database in the .ENV file
  • I deleted all migrations and let just the passwords and user migrations unchanged (fresh).
  • I deleted the log file and emptied the \storage\framework\views directory
  • I restarted the server.

Basically I have a new app. My goal ist migrate one by one each table to figure out where the problem is.

I run the first migration (just user table and passwords)

php artisan migrate

and get the exact same error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'street-box.chanels' doesn't exist

The question is:

Where Laravel store the information about tables if I have not migrations and a fresh database with a new name?

EDIT: My migrations are fresh, out of the box. The new database has the same name

Usertable

<?php

use Illuminate\Support\Facades\Schema;
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('name');
            $table->string('slug')->unique();
            $table->string('email')->unique();
            $table->string('password');
            $table->integer('role_id')->index()->default(3);
            $table->rememberToken();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}

Passwort

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePasswordResetsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('password_resets', function (Blueprint $table) {
            $table->string('email')->index();
            $table->string('token');
            $table->timestamp('created_at')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('password_resets');
    }
}
Rafael Munoz
  • 636
  • 1
  • 7
  • 27
  • Can you share that migration? The user migration? – Niklesh Raut Apr 17 '18 at 05:00
  • Is your new db name is `street-box` ? Or is it old ? – Niklesh Raut Apr 17 '18 at 05:01
  • Laravel uses a table named `migrations` to store info about migrations and table – Niklesh Raut Apr 17 '18 at 05:04
  • Did you check this post? https://stackoverflow.com/questions/30220377/how-do-laravel-migrations-work – Eazy Sam Apr 17 '18 at 05:16
  • @C2486 I edited my answer. Basically I ha restarted the project. The "migration" is also new. – Rafael Munoz Apr 17 '18 at 05:24
  • @Easy Sam I have checked that post. I would say I a not longer new in Laravel, but it seems that Laravel store somewhere else the iformation about tables. Since I deleted all migrations and made a new Database there is not way it asks me for a table that in that moment is in the future. – Rafael Munoz Apr 17 '18 at 05:27
  • 1
    Did you run `composer dump-autoload` after deleting migrations? I ran into the same issue once. – Muhammad Nauman Apr 17 '18 at 06:24
  • When you say you have a new app - does it mean you have a fresh installation of Laravel - or you just removed all migrations? If you're working on the existing project, check if any of the dependencies uses table name `street-box` - on another note, I would probably stick to underscores for table names rather than using hyphen. – Sebastian Sulinski Apr 17 '18 at 06:29
  • @SebastianSulinski, I meant I just removed the migrations. The project has been running a while and I can not start again from scratch. I wil have a look to the dependencies. Thanks – Rafael Munoz Apr 17 '18 at 06:57

0 Answers0