1

I am running exiting laravel project in homestead. When run php artisan migrate get the error.

Here is full error.

In Connection.php line 664:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'forum.chanel' doesn't exist (SQL: select * from `chanel`)  


In Connection.php line 326:

  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'forum.chanel' doesn't exist 

This is my chanel table

public function up()
    {
        Schema::create('chanels', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->string('slug');
            $table->timestamps();
        });
    }

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

Why i getting the error and how can i solve this error?

Get the error when run composer update

enter image description here

Shunhra Sarker
  • 187
  • 1
  • 2
  • 15

3 Answers3

0

You need to check your migration table to see if this migration was already run in the past, it is commong that developers change the code after they run the migration.

Or, you might have some even / interception that is running the query select * from chanel just before the migration running, and it making the migration to fail.

Avi Fatal
  • 1,550
  • 8
  • 8
0

It looks like you're model name and table name are not in sync, Before this remove all tables from DB it could be problem or migration arrangement in migrations table run composer dumpa then

Try updating your model by specifying $table name,

class Chanel extends Model{
    public $table = "chanels";
Vipertecpro
  • 3,056
  • 2
  • 24
  • 43
  • Can you please remove all tables from db then migrate again, it is also the case when you're seeding any table data before it's existence. – Vipertecpro Mar 31 '19 at 06:47
0

First need to fresh migration type below command

php artisan migrate:fresh

then run new model with migration file with below command

php artisan make:model chanel -m

with this command auto create a migration file and model file edit migration file location in {your app}\database\migrations

  $table->string('title');
  $table->string('slug');

added above line into public function up(){ // code }

now run migration type below code

php artisan migrate

I this this will help you

Akbor
  • 1,280
  • 1
  • 9
  • 11