最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

詳細(xì)Laravel5.5執(zhí)行表遷移命令出現(xiàn)表為空的解決方案

 更新時(shí)間:2018年07月06日 09:25:30   作者:Corwien  
這篇文章主要介紹了詳細(xì)Laravel5.5執(zhí)行表遷移命令出現(xiàn)表為空的解決方案,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

今天在使用一個(gè)第三方包 laravel-admin 時(shí),出現(xiàn)了這樣的錯(cuò)誤:SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '',折騰了好久,終于知道了解決方法,原來是配置文件的緩存沒有清理。

一、問題

vagrant@homestead:~/Code/laravel-shop$ php artisan admin:install

錯(cuò)誤提示:

In Connection.php line 664:

  SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table `` (`id` int uns
  igned not null auto_increment primary key, `username` varchar(190) not null, `password` varchar(60) not null, `name
  ` varchar(255) not null, `avatar` varchar(255) null, `remember_token` varchar(100) null, `created_at` timestamp nul
  l, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)


In Connection.php line 452:

  SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''

二、解決方案

database/migrations/2016_01_04_173148_create_admin_table.php

<?php

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

class CreateAdminTable extends Migration
{
  /**
   * Run the migrations.
   *
   * @return void
   */
  public function up()
  {
    $connection = config('admin.database.connection') ?: config('database.default');

    // dd(app('config'));
    Schema::connection($connection)->create(config('admin.database.users_table'), function (Blueprint $table) {
      $table->increments('id');
      $table->string('username', 190)->unique();
      $table->string('password', 60);
      $table->string('name');
      $table->string('avatar')->nullable();
      $table->string('remember_token', 100)->nullable();
      $table->timestamps();
    });

    Schema::connection($connection)->create(config('admin.database.roles_table'), function (Blueprint $table) {
      $table->increments('id');
      $table->string('name', 50)->unique();
      $table->string('slug', 50);
      $table->timestamps();
    });

    Schema::connection($connection)->create(config('admin.database.permissions_table'), function (Blueprint $table) {
      $table->increments('id');
      $table->string('name', 50)->unique();
      $table->string('slug', 50);
      $table->string('http_method')->nullable();
      $table->text('http_path')->nullable();
      $table->timestamps();
    });

    Schema::connection($connection)->create(config('admin.database.menu_table'), function (Blueprint $table) {
      $table->increments('id');
      $table->integer('parent_id')->default(0);
      $table->integer('order')->default(0);
      $table->string('title', 50);
      $table->string('icon', 50);
      $table->string('uri', 50)->nullable();

      $table->timestamps();
    });

    Schema::connection($connection)->create(config('admin.database.role_users_table'), function (Blueprint $table) {
      $table->integer('role_id');
      $table->integer('user_id');
      $table->index(['role_id', 'user_id']);
      $table->timestamps();
    });

    Schema::connection($connection)->create(config('admin.database.role_permissions_table'), function (Blueprint $table) {
      $table->integer('role_id');
      $table->integer('permission_id');
      $table->index(['role_id', 'permission_id']);
      $table->timestamps();
    });

    Schema::connection($connection)->create(config('admin.database.user_permissions_table'), function (Blueprint $table) {
      $table->integer('user_id');
      $table->integer('permission_id');
      $table->index(['user_id', 'permission_id']);
      $table->timestamps();
    });

    Schema::connection($connection)->create(config('admin.database.role_menu_table'), function (Blueprint $table) {
      $table->integer('role_id');
      $table->integer('menu_id');
      $table->index(['role_id', 'menu_id']);
      $table->timestamps();
    });

    Schema::connection($connection)->create(config('admin.database.operation_log_table'), function (Blueprint $table) {
      $table->increments('id');
      $table->integer('user_id');
      $table->string('path');
      $table->string('method', 10);
      $table->string('ip', 15);
      $table->text('input');
      $table->index('user_id');
      $table->timestamps();
    });
  }

  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down()
  {
    $connection = config('admin.database.connection') ?: config('database.default');

    Schema::connection($connection)->dropIfExists(config('admin.database.users_table'));
    Schema::connection($connection)->dropIfExists(config('admin.database.roles_table'));
    Schema::connection($connection)->dropIfExists(config('admin.database.permissions_table'));
    Schema::connection($connection)->dropIfExists(config('admin.database.menu_table'));
    Schema::connection($connection)->dropIfExists(config('admin.database.user_permissions_table'));
    Schema::connection($connection)->dropIfExists(config('admin.database.role_users_table'));
    Schema::connection($connection)->dropIfExists(config('admin.database.role_permissions_table'));
    Schema::connection($connection)->dropIfExists(config('admin.database.role_menu_table'));
    Schema::connection($connection)->dropIfExists(config('admin.database.operation_log_table'));
  }
}

清除配置文件緩存

vagrant@homestead:~/Code/laravel-shop$ php artisan config:cache

再次執(zhí)行發(fā)布命令,就可以了:

vagrant@homestead:~/Code/laravel-shop$ php artisan admin:install
Migrating: 2016_01_04_173148_create_admin_table
Migrated: 2016_01_04_173148_create_admin_table
Admin directory was created: /app/Admin
HomeController file was created: /app/Admin/Controllers/HomeController.php
ExampleController file was created: /app/Admin/Controllers/ExampleController.php
Bootstrap file was created: /app/Admin/bootstrap.php
Routes file was created: /app/Admin/routes.php
vagrant@homestead:~/Code/laravel-shop$

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Laravel 5框架學(xué)習(xí)之表單

    Laravel 5框架學(xué)習(xí)之表單

    Laravel 5.0 新引入的表單請(qǐng)求 (Form Request) 特性提供了集規(guī)范性 (差不多就是 "最佳實(shí)踐" 的意思) 和便捷性 (這是比之前任何一種選擇都更強(qiáng)大也更便捷的方式) 于一體的, 在 Laravel 中執(zhí)行數(shù)據(jù)檢查和驗(yàn)證的新手段.
    2015-04-04
  • ThinkPHP訪問不存在的模塊跳轉(zhuǎn)到404頁(yè)面的方法

    ThinkPHP訪問不存在的模塊跳轉(zhuǎn)到404頁(yè)面的方法

    這篇文章主要介紹了ThinkPHP訪問不存在的模塊跳轉(zhuǎn)到404頁(yè)面的方法,需要的朋友可以參考下
    2014-06-06
  • php守護(hù)進(jìn)程 加linux命令nohup實(shí)現(xiàn)任務(wù)每秒執(zhí)行一次

    php守護(hù)進(jìn)程 加linux命令nohup實(shí)現(xiàn)任務(wù)每秒執(zhí)行一次

    那么有了這個(gè)命令以后我們php就寫成shell 腳本使用循環(huán)來讓我們腳本一直運(yùn)行下去,不管我們終端窗口是否關(guān)閉都能夠讓我們php 腳本一直運(yùn)行下去。
    2011-07-07
  • Laravel多域名下字段驗(yàn)證的方法

    Laravel多域名下字段驗(yàn)證的方法

    這篇文章主要給大家介紹了關(guān)于Laravel多域名下字段驗(yàn)證的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Laravel具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • PHP 使用位運(yùn)算實(shí)現(xiàn)四則運(yùn)算的代碼

    PHP 使用位運(yùn)算實(shí)現(xiàn)四則運(yùn)算的代碼

    這篇文章主要介紹了PHP 使用位運(yùn)算實(shí)現(xiàn)四則運(yùn)算的代碼,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-01-01
  • PHP微信紅包生成代碼分享

    PHP微信紅包生成代碼分享

    這篇文章主要介紹了PHP微信紅包API接口,針對(duì)PHP微信公眾號(hào)自動(dòng)發(fā)送紅包API,PHP微信紅包API接口的主要代碼進(jìn)行分析,感興趣的小伙伴們可以參考一下
    2016-10-10
  • Yii2.0框架模型添加/修改/刪除數(shù)據(jù)操作示例

    Yii2.0框架模型添加/修改/刪除數(shù)據(jù)操作示例

    這篇文章主要介紹了Yii2.0框架模型添加/修改/刪除數(shù)據(jù)操作,結(jié)合實(shí)例形式分析了Yii2.0使用模型操作數(shù)據(jù)的添加、修改、刪除相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2019-07-07
  • Laravel框架運(yùn)行出錯(cuò)提示RuntimeException No application encryption key has been specified.解決方法

    Laravel框架運(yùn)行出錯(cuò)提示RuntimeException No application encryption ke

    這篇文章主要介紹了Laravel框架運(yùn)行出錯(cuò)提示RuntimeException No application encryption key has been specified.解決方法,涉及Laravel框架相關(guān)配置、設(shè)置與運(yùn)行操作技巧,需要的朋友可以參考下
    2019-04-04
  • Laravel中錯(cuò)誤與異常處理的用法示例

    Laravel中錯(cuò)誤與異常處理的用法示例

    異常拋出在開發(fā)中錯(cuò)誤處理是非常重要的,下面這篇文章主要給大家介紹了關(guān)于Laravel中錯(cuò)誤與異常處理用法的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面來一起看看吧
    2018-09-09
  • php header函數(shù)的常用http頭設(shè)置

    php header函數(shù)的常用http頭設(shè)置

    這篇文章主要介紹了php header函數(shù)的常用http頭設(shè)置,本文直接給出代碼實(shí)例,代碼中包含詳細(xì)注釋,需要的朋友可以參考下
    2015-06-06

最新評(píng)論

浪卡子县| 雅江县| 炎陵县| 南平市| 醴陵市| 读书| 偏关县| 平乡县| 晴隆县| 云安县| 颍上县| 襄樊市| 金山区| 南皮县| 响水县| 宜州市| 财经| 响水县| 犍为县| 肃南| 武穴市| 万安县| 台东县| 长治市| 宁化县| 慈利县| 韩城市| 桃源县| 宝兴县| 博乐市| 新密市| 剑河县| 保山市| 盐城市| 通海县| 桦川县| 松江区| 北宁市| 宝丰县| 四子王旗| 扎兰屯市|