From 7a6d8adcb57e28e8aa828e3f8660f19f818eea82 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 20 Dec 2025 23:44:15 -0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9C=A8=20seed=20=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20GENESIS=20=E7=B3=BB=E7=BB=9F=E7=A7=8D=E5=AD=90?= =?UTF-8?q?=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题原因: - seed.ts 会删除所有 userAccount 记录 - 即使 migration 创建了 GENESIS 用户,seed 运行后也会被删除 - 之前的系统账户使用 userId 1-4,但 GENESIS 应该是 userId 1 解决方案: - 将 GENESIS 用户添加到 SYSTEM_ACCOUNTS 数组 - userId: 1, accountSequence: 'SYSTEM00001', referralCode: 'GENESIS' - 其他系统账户的 userId 顺延到 2-5 系统账户列表: - userId 1: GENESIS (系统种子用户,用于注册推荐码) - userId 2: 总部社区 (HQ000001) - userId 3: 成本费账户 (COST0002) - userId 4: 运营费账户 (OPER0003) - userId 5: RWAD底池账户 (POOL0004) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- backend/services/identity-service/prisma/seed.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/services/identity-service/prisma/seed.ts b/backend/services/identity-service/prisma/seed.ts index 79819311..b5e23f60 100644 --- a/backend/services/identity-service/prisma/seed.ts +++ b/backend/services/identity-service/prisma/seed.ts @@ -23,27 +23,34 @@ const ADMIN_ACCOUNTS = [ const SYSTEM_ACCOUNTS = [ { userId: BigInt(1), + accountSequence: 'SYSTEM00001', // 系统种子用户(用于注册推荐码) + nickname: '系统', + referralCode: 'GENESIS', + status: 'ACTIVE', + }, + { + userId: BigInt(2), accountSequence: 'S0000000001', // 总部社区 nickname: '总部社区', referralCode: 'HQ000001', status: 'SYSTEM', }, { - userId: BigInt(2), + userId: BigInt(3), accountSequence: 'S0000000002', // 成本费账户 nickname: '成本费账户', referralCode: 'COST0002', status: 'SYSTEM', }, { - userId: BigInt(3), + userId: BigInt(4), accountSequence: 'S0000000003', // 运营费账户 nickname: '运营费账户', referralCode: 'OPER0003', status: 'SYSTEM', }, { - userId: BigInt(4), + userId: BigInt(5), accountSequence: 'S0000000004', // RWAD底池账户 nickname: 'RWAD底池账户', referralCode: 'POOL0004', @@ -114,7 +121,7 @@ async function main() { console.log('Database seeded successfully!'); console.log(`- Initialized account sequence generator for date ${dateKey}`); - console.log(`- Created ${SYSTEM_ACCOUNTS.length} system accounts (S0000000001-S0000000004)`); + console.log(`- Created ${SYSTEM_ACCOUNTS.length} system accounts (including GENESIS seed user)`); console.log(`- Created ${ADMIN_ACCOUNTS.length} admin accounts`); }