up()
up()
Run the migrations.
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
class CreateSystemDeptTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('system_dept', function (Blueprint $table) {
$table->engine = 'Innodb';
$table->comment('部门信息表');
$table->addColumn('bigInteger', 'id', ['unsigned' => true, 'comment' => '主键']);
$table->addColumn('bigInteger', 'parent_id', ['unsigned' => true, 'comment' => '父ID']);
$table->addColumn('string', 'level', ['length' => 500, 'comment' => '组级集合']);
$table->addColumn('string', 'name', ['length' => 30, 'comment' => '部门名称']);
$table->addColumn('string', 'leader', ['length' => 20, 'comment' => '负责人'])->nullable();
$table->addColumn('string', 'phone', ['length' => 11, 'comment' => '联系电话'])->nullable();
$table->addColumn('char', 'status', ['length' => 1, 'default' => '0', 'comment' => '状态 (0正常 1停用)'])->nullable();
$table->addColumn('tinyInteger', 'sort', ['unsigned' => true, 'default' => 0, 'comment' => '排序'])->nullable();
$table->addColumn('bigInteger', 'created_by', ['comment' => '创建者'])->nullable();
$table->addColumn('bigInteger', 'updated_by', ['comment' => '更新者'])->nullable();
$table->addColumn('timestamp', 'created_at', ['precision' => 0, 'comment' => '创建时间'])->nullable();
$table->addColumn('timestamp', 'updated_at', ['precision' => 0, 'comment' => '更新时间'])->nullable();
$table->addColumn('timestamp', 'deleted_at', ['precision' => 0, 'comment' => '删除时间'])->nullable();
$table->addColumn('string', 'remark', ['length' => 255, 'comment' => '备注'])->nullable();
$table->primary('id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('system_dept');
}
}