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

时间:2017-03-02 17:31:46

标签: php laravel-5.3

我正在尝试构建一个表,但是当我运行此命令时#34; php artisan migrate"发生此错误:

[照亮\数据库\ QueryException]
  SQLSTATE [42S02]:找不到基表或视图:1146表' epharmacy.medici
  未列名'不存在(SQL:alter table medicines add id int unsigned 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 :(得分: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');
    }    

}