* * 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; } }