我使用迁移创建了一个表,类似这样的代码:
现在我想从“列表”中删除这两列。
但有人可以编写这个新迁移,必须查找并删除这两列吗?
Schema::create('listings', function (Blueprint $table) {
$table->increments('id');
$table->decimal('original_price', 10, 2);
$table->decimal('discouted_price', 10, 2);
$table->integer('city_id')->index()->unsigned()->nullable();
$table->foreign('city_id')->references('id')->on('cities');
$table->integer('destination_city_id')->unsigned()->index();
$table->foreign('destination_city_id')->references('id')->on('cities');
$table->string('url');
$table->string('titile');
$table->text('description')->nullable();
$table->dateTime('expires_at');
$table->integer('clicks')->default('0');
$table->integer('views')->default('0');
$table->timestamps();
$table->softDeletes();
});
现在我想从“列表”中删除这两列。
$table->integer('city_id')->index()->unsigned()->nullable();
$table->foreign('city_id')->references('id')->on('cities');
$table->integer('destination_city_id')->unsigned()->index();
$table->foreign('destination_city_id')->references('id')->on('cities');
但有人可以编写这个新迁移,必须查找并删除这两列吗?
php artisan migrate
重新迁移该表。 - Hiren GoheldropColumn
方法。在删除列之前,请确保将doctrine/dbal
依赖项添加到您的composer.json
文件中。 - Hiren Gohel