xxxxxxxxxx
Schema::table('users', function (Blueprint $table) {
if (Schema::hasColumn('users', 'phone')) {
$table->dropColumn('phone');
}
});
xxxxxxxxxx
Class RemoveCommentViewCount extends Migration
{
public function up()
{
Schema::table('articles', function($table) {
$table->dropColumn('comment_count');
$table->dropColumn('view_count');
});
}
public function down()
{
Schema::table('articles', function($table) {
$table->integer('comment_count');
$table->integer('view_count');
});
}
}
xxxxxxxxxx
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
// Specify the table name and column name to be dropped
$tableName = 'your_table_name';
$columnName = 'your_column_name';
// Check if the column exists before dropping
if (Schema::hasColumn($tableName, $columnName)) {
// Drop the column
Schema::table($tableName, function (Blueprint $table) use ($columnName) {
$table->dropColumn($columnName);
});
}
xxxxxxxxxx
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DropColumnFromTable extends Migration
{
/**
* Run the migration.
*
* @return void
*/
public function up()
{
Schema::table('table_name', function (Blueprint $table) {
$table->dropColumn('column_name');
});
}
/**
* Reverse the migration (rollback).
*
* @return void
*/
public function down()
{
Schema::table('table_name', function (Blueprint $table) {
$table->addColumn('data_type', 'column_name')->nullable();
});
}
}
xxxxxxxxxx
Schema::table('clients', function (Blueprint $table) {
$table->string('UserDomainName');
});