【发布时间】:2019-06-08 03:11:27
【问题描述】:
我已经有一个表名table_one. 现在我想再添加两列。到目前为止一切正常。但在我的方法中,我想检查我的表中是否存在列,例如dropIfExists('table').
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('table_one', function (Blueprint $table) {
$table->string('column_one')->nullable();
$table->string('column_two')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('table_one', function (Blueprint $table) {
// in here i want to check column_one and column_two exists or not
$table->dropColumn('column_one');
$table->dropColumn('column_two');
});
}
【问题讨论】: