Проверьте, существует ли столбец в файле миграции Laravel ⇐ Php

Кемеровские программисты php общаются здесь
Anonymous
Проверьте, существует ли столбец в файле миграции Laravel

Сообщение Anonymous »

У меня уже есть таблица с именем 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');
});
}


Подробнее здесь: https://stackoverflow.com/questions/541 ... ation-file

Вернуться в «Php»