Laravel 5 Migrate基本表或视图未找到:1146 [英] Laravel 5 Migrate Base table or view not found: 1146

查看:164
本文介绍了Laravel 5 Migrate基本表或视图未找到:1146的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很大的问题.我正在尝试朗姆酒php artisan migrate生成表迁移,但是我正在

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.ERROR:异常'PDOException'与 消息'SQLSTATE [42S02]:找不到基表或视图:1146表 "testing.permissions"不存在 D:\ xampp \ htdocs \ LMS-testing \ vendor \ laravel \ framework \ src \ Illuminate \ Database \ Connection.php:333

[2016-03-08 05:49:01] local.ERROR: exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'testing.permissions' doesn't exist' in D:\xampp\htdocs\LMS-testing\vendor\laravel\framework\src\Illuminate\Database\Connection.php:333

错误.我曾尝试并在错误的互联网上搜索,但没有任何解决方法.

error. I have tried and search on internet, where i have mistaken, but i did not get any solution.

我也尝试过基础表或视图不找到:1146表Laravel 5 ,但是我没有成功.

I have also tried Base table or view not found: 1146 Table Laravel 5 and Doing a Laravel tutorial, getting "Base table or view not found: 1146 Table 'sdbd_todo.migrations' doesn't exist", but i did not get succeed.

我也尝试过运行php artisan list,但是再次出现相同的错误.我不知道为什么请给我建议解决方案.

I have also tried to run php artisan list, but again i am getting same error. I don't know why. Please suggest me the solution.

已更新

**RolesPermission migration table**

Schema::create('roles', function(Blueprint $table){
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('label');
            $table->string('description')->nullable();
            $table->timestamps();            
        });

        Schema::create('permissions', function(Blueprint $table){
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('label');
            $table->string('description')->nullable();
            $table->timestamps();            
        });

        Schema::create('permission_role', function(Blueprint $table){
            $table->integer('permission_id')->unsigned();
            $table->integer('role_id')->unsigned();

            $table->foreign('permission_id')
                    ->references('id')
                    ->on('permissions')
                    ->onDelete('cascade');

            $table->foreign('role_id')
                    ->references('id')
                    ->on('roles')
                    ->onDelete('cascade');

            $table->primary(['permission_id', 'role_id']);
        });

        Schema::create('role_user', function(Blueprint $table){
            $table->integer('role_id')->unsigned();
            $table->integer('user_id')->unsigned();

            $table->foreign('role_id')
                    ->references('id')
                    ->on('roles')
                    ->onDelete('cascade');

            $table->foreign('user_id')
                    ->references('id')
                    ->on('users')
                    ->onDelete('cascade');

            $table->primary(['role_id', 'user_id']);

        });


.env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=W8YWZe3LCngvZzexH3WLWqCDlYRSufuy

DB_HOST=127.0.0.1
DB_DATABASE=testing
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=log
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

推荐答案

检查您的迁移文件,也许您正在使用Schema :: table,如下所示:

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

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

如果要创建新表,则必须使用Schema :: create:

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

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

Laracast 更多信息,请参见此链接.

Laracast More information in this link.

这篇关于Laravel 5 Migrate基本表或视图未找到:1146的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆