feat: 添加统一数据库初始化命令,简化数据库迁移和种子填充流程;新增基础和演示数据填充器

This commit is contained in:
2026-06-09 17:41:37 +08:00
parent 5bd7517ce9
commit bbdb69dabb
7 changed files with 199 additions and 21 deletions

View File

@@ -11,27 +11,10 @@ final class DatabaseSeeder extends Seeder
public function run(): void
{
// 全环境可用的基础枚举数据
$this->call([
CurrencySeeder::class,
PlayTypeSeeder::class,
OperationalConfigV1Seeder::class,
OddsPrizeScopesBackfillSeeder::class,
/** 对齐玩法目录与 active/draft 配置行(修复历史子集种子) */
PlayOperationalAlignmentSeeder::class,
LotterySettingsSeeder::class,
]);
$this->call([FoundationSeeder::class]);
// 演示管理员 + 演示玩家 + 演示期号:**勿在生产库执行**(或确保 APP_ENV≠production
if (! app()->environment('production')) {
$this->call([
AdminRbacAndUserSeeder::class,
DevPlayerAndWalletSeeder::class,
DrawDemoSeeder::class,
// 仪表盘:对齐「大厅 resolve 当期」+ 多场景演示期(-996 settled / -995 pending
DashboardHallFixtureSeeder::class,
DashboardSecondaryScenariosSeeder::class,
]);
$this->call([LocalDemoSeeder::class]);
}
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
/**
* 全环境通用的基础数据。
*
* 约束:
* - 只能放可重复执行、幂等、安全用于生产的枚举/配置/权限同步类种子
* - 不放演示账号、演示玩家、演示期号等开发数据
*/
final class FoundationSeeder extends Seeder
{
use WithoutModelEvents;
public function run(): void
{
$this->call([
CurrencySeeder::class,
PlayTypeSeeder::class,
OperationalConfigV1Seeder::class,
OddsPrizeScopesBackfillSeeder::class,
PlayOperationalAlignmentSeeder::class,
LotterySettingsSeeder::class,
]);
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
/**
* 本地/测试联调用的演示数据。
*
* 约束:
* - 绝不在 production 环境默认执行
* - 仅包含便于联调的账号、玩家、期号、仪表盘样例等
*/
final class LocalDemoSeeder extends Seeder
{
use WithoutModelEvents;
public function run(): void
{
$this->call([
AdminRbacAndUserSeeder::class,
DevPlayerAndWalletSeeder::class,
DrawDemoSeeder::class,
DashboardHallFixtureSeeder::class,
DashboardSecondaryScenariosSeeder::class,
]);
}
}