【发布时间】:2015-03-01 05:47:12
【问题描述】:
我正在创建一个这样的表,
Schema::create('booking_segments', function (Blueprint $table) {
$table->increments('id');
$table->datetime('start')->index();
$table->integer('duration')->unsigned();
$table->string('comments');
$table->integer('booking_id')->unsigned();
$table->foreign('booking_id')->references('id')->on('bookings')->onDelete('cascade');
});
但我想多加一列。在原始 SQL 中看起来像这样:
ALTER TABLE booking_segments ADD COLUMN `end` DATETIME AS (DATE_ADD(`start`, INTERVAL duration MINUTE)) PERSISTENT AFTER `start`
如何将它添加到我的迁移中?我还需要在上面创建一个索引。
【问题讨论】: