Files
wh-api/app/Service/MigrateService.php
ykxiao 0b2299c427
Some checks failed
Build Docker / build (push) Has been cancelled
协程版仓库后端项目
2025-07-08 14:59:47 +08:00

44 lines
1.4 KiB
PHP

<?php
/**
* Author: ykxiao
* Date: 2025/6/4
* Time: 下午1:57
* Description:
*
* (c) ykxiao <yk_9001@hotmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
declare(strict_types=1);
namespace App\Service;
use Hyperf\Database\Schema\Blueprint;
class MigrateService
{
/***
* 在创建的时候自动添加如下字段
* @param Blueprint $blueprint
* @return Blueprint
*/
public static function migrateCreateInfo(Blueprint $blueprint): Blueprint
{
$blueprint->integer('creator_id')->default(0)->unsigned()->comment('创建人ID');
$blueprint->string('creator_name', 45)->default('')->comment('创建人姓名');
$blueprint->integer('created_at')->default(0)->unsigned()->comment('创建时间');
$blueprint->integer('updated_at')->default(0)->unsigned()->comment('更新时间');
$blueprint->integer('deleted_at')->nullable()->unsigned()->comment('软删除时间');
return $blueprint;
}
public static function migrateTime(Blueprint $blueprint): Blueprint
{
$blueprint->integer('created_at')->default(0)->unsigned()->comment('创建时间');
$blueprint->integer('updated_at')->default(0)->unsigned()->comment('更新时间');
$blueprint->integer('deleted_at')->nullable()->unsigned()->comment('软删除时间');
return $blueprint;
}
}