dootask/database/migrations/2022_11_17_103811_add_users_department.php
2023-03-24 09:08:53 +08:00

35 lines
790 B
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddUsersDepartment extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
if (!Schema::hasColumn('users', 'department')) {
$table->string('department', 255)->nullable()->default('')->after('identity')->comment('所属部门');
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn("department");
});
}
}