首页 文章

未找到基表或视图:1146表'epharmacy.medicines'不存在

提问于
浏览
0

我正在尝试构建一个表,但是当我运行此命令“php artisan migrate”时出现此错误:

[照亮\数据库\ QueryException]
SQLSTATE [42S02]:未找到基表或视图:1146表'epharmacy.medici
nes ' doesn' t存在(SQL:alter table medicines add id int unsigned not not
null auto_increment主键,添加 name varchar(255)not null,添加 typ e varchar(255)not null,添加 potency varchar(255)not null,添加 created _at timestamp null,添加 updated_at timestamp null

移民:

<?php

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

class CreateMedicineTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('medicines', function (Blueprint $table) {
            $table->increments('id');
            $table->String('name');
            $table->String('type');
            $table->String('potency');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('medicines', function (Blueprint $table) {
            //
        });
    }
}

1 回答

  • 0

    根据the docs,它需要是:

    <?php
    
    use Illuminate\Support\Facades\Schema;
    use Illuminate\Database\Schema\Blueprint;
    use Illuminate\Database\Migrations\Migration;
    
    class CreateMedicineTable extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            Schema::create('medicines', function (Blueprint $table) {
                $table->increments('id');
                $table->string('name');
                $table->string('type');
                $table->string('potency');
                $table->timestamps();
            });
        }
    
        /**
         * Reverse the migrations.
         *
         * @return void
         */
        public function down()
        {
            Schema::dropIfExists('medicines');
        }
    

    }

相关问题