Laravel 5 Migrate Base table or view not found: 1146

前端 未结 12 541
情话喂你
情话喂你 2020-12-11 01:06

I am in big problem. I am trying to rum php artisan migrate to generate table migration, but i am getting

[2016-03-08 05:49:01] local.ERR

相关标签:
12条回答
  • 2020-12-11 01:49

    Check all of your service providers. In one of the boot methods, a model may be called, the migration to which has not yet been run.

    0 讨论(0)
  • 2020-12-11 01:50

    Check your migration file, maybe you are using Schema::table, like this:

    Schema::table('table_name', function ($table)  {
        // ...
    });
    

    If you want to create a new table you must use Schema::create:

    Schema::create('table_name', function ($table)  {
        // ...
    });
    

    Laracast More information in this link.

    0 讨论(0)
  • 2020-12-11 01:55

    In case anybody else runs in to this I just had the same issue and the reason it was happening was because I had created several commands and then needed to rollback my db to rerun the migrations.

    To fix it I had to comment out the contents of the

    protected $commands = []
    

    in app\Console\Kernel.php file.

    Phew!!!! :-)

    0 讨论(0)
  • 2020-12-11 01:56

    I had this problem when I tried to migrate new database. I had a function in AuthServiceProvider which selects all permissions. I commented that function and the problem was fixed.

    0 讨论(0)
  • 2020-12-11 01:59

    The problem is that the foreign keys are added but cannot find the table because it hasn't been created.

    1) make tables without foreign keys

    2) Make a 9999_99_99_999999_create_foreign_keys.php file

    3) put there the foreign keys you want. With the 999..9 .php file it makes sure that it does the foreign keys last after the tables have been made.

    4) You have added the tables first and then added the foreign keys. This will work.

    0 讨论(0)
  • 2020-12-11 02:01

    I ran it to a similar problem.

    Seems like I executed a Model query in the routes file. So it executes every time, even before running the actual migration.

    //Problematic code
    Route::view('users', 'users', [ 'users' => User::all() ]);
    

    So I changed it to

    Route::get('/users', function () {
        return view('users', ['users' => User::all()]);
    });
    

    And everything works fine. Make sure that no Model queries is excecuted on the execution path and then try migrating.

    0 讨论(0)
提交回复
热议问题