php artisan migrate:fresh 之后出现错误:
SQLSTATE[42000]:语法错误或访问冲突:1072 表中不存在键列“proform_id”(SQL:alter tableproforms
添加约束proforms_proform_id_foreign
外键(proform_id
)引用proforms
(id
)删除级联)
这是生成错误的迁移:2020_08_08_093303_create_dynamic_field.php
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateDynamicField extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('dynamic_fields', function (Blueprint $table) {
$table->increments('id');
$table->string('id_pozycji')->nullable();
$table->string('name')->nullable();
$table->string('PKWIU')->nullable();
$table->integer('quantity')->nullable();
$table->integer('unit')->nullable();
$table->integer('netunit')->nullable();
$table->integer('nettotal')->nullable();
$table->integer('VATrate')->nullable();
$table->integer('grossunit')->nullable();
$table->integer('grosstotal')->nullable();
$table->integer('proform_id')->nullable();
$table->timestamps();
$table->time('deleted_at')->nullable();
});
Schema::table('proforms', function (Blueprint $table){
$table->foreign('proform_id')
->references('id')
->on('proforms')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('dynamic_fields');
}
}
白猪掌柜的
开满天机