Search code examples
phpmysqllaravel-5migrationlaravel-seeding

Table is existed but getting error SQLSTATE[42S02]: Base table or view not found: 1146 Table 'exyz.input_fields' doesn't exist


i'm trying to insert values from laravel seeder. All other tables data inserted but i'm stuck on input_fields table. Even it's working on my local Mamp server absoultely fine but when i try to run on Live server getting error but as i seen the table name is existed in my database. I run "composer dumpautoload" too but still face same issue.

inputField.php

namespace App;

use Illuminate\Database\Eloquent\Model;

class inputField extends Model
{
    protected $table = 'input_fields';

    public function dropDown()
    {
        return $this->belongsTo('App\dropDown', 'drop_id');
    }
}

2017_10_13_093801_input_Fields

Schema::create('input_Fields', function (Blueprint $table) {
            $table->increments('id');
            $table->string('field_name');
            $table->string('cat_id');
            $table->string('description');
            $table->string('drop_id')->nullable();
            $table->rememberToken();
            $table->timestamps();
        });

InputFieldsTableSeeder.php

        $inputvalue = new inputField();
        $inputvalue->field_name = 'Bilirubin Total';
        $inputvalue->cat_id = '1';
        $inputvalue->description = '0.0 - 1.2';
        $inputvalue->save();


Solution

  • You're a bit inconsistent with the letter casing.

    $table = 'input_fields' 
    

    and

    create('input_Fields', .... 
    

    Different environments/configurations can have different settings for case sensitivity for table names. Try and be consistent and change to

    create('input_fields', ...) 
    

    and it should work better.