This article mainly describes the Laravel5.5 Execution Table Migration command appears empty solution, has a certain reference value, now share to everyone, have the need for friends can refer to
today in the use of a third-party package laravel-admin, there have been such errors:
SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''
, tossing for a long time, finally know the solution, the original configuration file cache is not cleaned.
First, the question
vagrant@homestead:~/code/laravel-shop$ PHP Artisan Admin:install
Error message:
In connection.php line 664: sqlstate[42000]: Syntax error or access violation:1103 incorrect table name ' (Sql:crea Te table ' (' id ' int uns igned NOT NULL auto_increment primary key, ' username ' varchar (a) NOT NULL, ' password ' Varc Har () is not null, ' name ' varchar (255) is not NULL, ' avatar ' varchar (255) NULL, ' remember_token ' varchar (+) NULL, ' Crea Ted_at ' timestamp nul L, ' updated_at ' timestamp null) default character set UTF8MB4 collate utf8mb4_unicode_ci) in Conn ection.php Line 452: sqlstate[42000]: Syntax error or access violation:1103 incorrect table name '
Second, the solution
database/migrations/2016_01_04_173148_create_admin_table.php
<?phpuse 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 ')?: Confi G (' Database.default '); DD (app (' config ')); Schema::connection ($connection)->create (config (' admin.database.users_table '), function (Blueprint $table) { $table->increments (' id '); $table->string (' username ',->unique); $table->string (' password ', 60); $table->string (' name '); $table->string (' Avatar ')->nullable (); $table->string (' Remember_token ', +)->nullable (); $table->timestamps (); }); Schema::connection ($connection)->create (config (' admin.database.roles_table '), function (Blueprint $table) { $table->increments (' id '); $table->stRing (' name ', ()->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 ', '->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 ', '->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 ')?: Con Fig (' 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 ')); }}
To clear the configuration file cache
vagrant@homestead:~/code/laravel-shop$ PHP Artisan Config:cache
To execute the Publish command again, you can:
vagrant@homestead:~/code/laravel-shop$ PHP Artisan Admin:installmigrating:2016_01_04_173148_create_admin_ tablemigrated: 2016_01_04_173148_create_admin_tableadmin Directory was created:/app/adminhomecontroller file was created:/app/admin/controllers/homecontroller.phpexamplecontroller file was created:/app/admin/controllers/ Examplecontroller.phpbootstrap file was created:/app/admin/bootstrap.phproutes file was created:/app/admin/ routes.phpvagrant@homestead:~/code/laravel-shop$
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!