Laravel5.5에서 테이블 마이그레이션 명령 실행 시 테이블이 비어있는 문제 해결 방법

不言
풀어 주다: 2023-04-02 16:28:01
원래의
2095명이 탐색했습니다.

이 글에서는 Laravel5.5에서 테이블 마이그레이션 명령을 실행할 때 테이블이 비어 있는 문제에 대한 해결 방법을 주로 소개합니다. 이제 필요한 친구들이 참고할 수 있도록 공유하겠습니다.

#🎜 🎜#오늘 타사 패키지 laravel-admin을 사용할 때 다음 오류가 발생했습니다: SQLSTATE[42000]: 구문 오류 또는 액세스 위반: 1103 잘못된 테이블 이름 '', 이후 오랫동안 고민하다가 마침내 해결책을 찾았는데, 알고 보니 구성 파일의 캐시가 지워지지 않은 것이었습니다.

1. 문제

vagrant@homestead:~/Code/laravel-shop$ php artisan admin:install
로그인 후 복사
오류 메시지: SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '',折腾了好久,终于知道了解决方法,原来是配置文件的缓存没有清理。

一、问题

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 ''
로그인 후 복사

错误提示:

<?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(&#39;admin.database.connection&#39;) ?: config(&#39;database.default&#39;);

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

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

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

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

            $table->timestamps();
        });

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

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

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

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

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

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

        Schema::connection($connection)->dropIfExists(config(&#39;admin.database.users_table&#39;));
        Schema::connection($connection)->dropIfExists(config(&#39;admin.database.roles_table&#39;));
        Schema::connection($connection)->dropIfExists(config(&#39;admin.database.permissions_table&#39;));
        Schema::connection($connection)->dropIfExists(config(&#39;admin.database.menu_table&#39;));
        Schema::connection($connection)->dropIfExists(config(&#39;admin.database.user_permissions_table&#39;));
        Schema::connection($connection)->dropIfExists(config(&#39;admin.database.role_users_table&#39;));
        Schema::connection($connection)->dropIfExists(config(&#39;admin.database.role_permissions_table&#39;));
        Schema::connection($connection)->dropIfExists(config(&#39;admin.database.role_menu_table&#39;));
        Schema::connection($connection)->dropIfExists(config(&#39;admin.database.operation_log_table&#39;));
    }
}
로그인 후 복사

二、解决方案

database/migrations/2016_01_04_173148_create_admin_table.php

vagrant@homestead:~/Code/laravel-shop$ php artisan config:cache
로그인 후 복사

2. 해결 방법

database/migrations/2016_01_04_173148_create_admin_table . php

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$
로그인 후 복사
구성 파일 캐시 지우기

rrreee

Publish 명령을 다시 실행하면 완료됩니다.

rrreee

위는 다음과 같습니다. 이 글의 내용 모든 내용이 모든 분들의 공부에 도움이 되었으면 좋겠습니다. 더 많은 관련 내용은 PHP 중국어 홈페이지를 주목해주세요!

관련 권장 사항:

laravel+Redis는 단순히 스트레스 테스트를 통과하는 대기열의 높은 동시 처리를 구현합니다

#🎜 🎜#nginx 구성 파일의 fastcgi_param 구성 오류에 대한 해결 방법

위 내용은 Laravel5.5에서 테이블 마이그레이션 명령 실행 시 테이블이 비어있는 문제 해결 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!