迁移收藏到新数据结构
This commit is contained in:
@@ -17,6 +17,7 @@ export async function GET(request: NextRequest) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
// 检查用户状态和执行迁移
|
||||
if (authInfo.username !== process.env.USERNAME) {
|
||||
// 非站长,检查用户存在或被封禁
|
||||
const userInfoV2 = await db.getUserInfoV2(authInfo.username);
|
||||
@@ -32,6 +33,13 @@ export async function GET(request: NextRequest) {
|
||||
console.log(`用户 ${authInfo.username} 播放记录未迁移,开始执行迁移...`);
|
||||
await db.migratePlayRecords(authInfo.username);
|
||||
}
|
||||
} else {
|
||||
// 站长也需要执行迁移(站长可能不在数据库中,直接尝试迁移)
|
||||
const userInfoV2 = await db.getUserInfoV2(authInfo.username);
|
||||
if (!userInfoV2 || !userInfoV2.playrecord_migrated) {
|
||||
console.log(`站长 ${authInfo.username} 播放记录未迁移,开始执行迁移...`);
|
||||
await db.migratePlayRecords(authInfo.username);
|
||||
}
|
||||
}
|
||||
|
||||
const records = await db.getAllPlayRecords(authInfo.username);
|
||||
|
||||
Reference in New Issue
Block a user