小编Pro*_*eAL的帖子

Laravel 8 SQLSTATE[42S02]:未找到基表或视图:1146 表,即使我正在尝试创建此表

我正在使用 Laravel 8。我正在尝试创建一个新表,但该表在数据库中不存在,并且没有任何其他同名表。我进行了迁移,这是迁移代码:

\n
<?php\n\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Support\\Facades\\Schema;\n\nclass CreateCertificateTable extends Migration\n{\n    /**\n     * Run the migrations.\n     *\n     * @return void\n     */\n    public function up()\n    {\n        Schema::table('certificate', function (Blueprint $table) {\n            $table->id();\n            $table->unsignedBigInteger('user_id');\n            $table->unsignedBigInteger('vac_id');\n            $table->time('last_shot_date');\n            $table->timestamps();\n\n            $table->foreign('user_id')->references('id')->on('users');\n            $table->foreign('vac_id')->references('id')->on('vaccination');\n        });\n    }\n\n    /**\n     * Reverse the migrations.\n     *\n     * @return void\n     */\n    public function down()\n    {\n        Schema::table('certificate', function (Blueprint $table) {\n            //\n        });\n    }\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n

做完之后

\n
php artisan migrate\n
Run Code Online (Sandbox Code Playgroud)\n

这是我收到的完整错误消息:

\n
   Illuminate\\Database\\QueryException\n\n  SQLSTATE[42S02]: Base table or view not found: 1146 Table …
Run Code Online (Sandbox Code Playgroud)

php migration database-migration laravel laravel-8

0
推荐指数
1
解决办法
1753
查看次数

标签 统计

database-migration ×1

laravel ×1

laravel-8 ×1

migration ×1

php ×1