我正在尝试构建一个表,但是当我运行此命令时#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
varchar(255)not null,添加
epotency
varchar(255)not null,添加created
timestamp null,添加
_atupdated_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) {
//
});
}
}
答案 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');
}
}