This commit is contained in:
44
app/Service/MigrateService.php
Normal file
44
app/Service/MigrateService.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user