Quitar el prefijo home_ de las 41 tablas del portal
El prefijo venía del nombre de la app Django (`home`), jubilada y borrada hoy, así que ya no significaba nada: home_stripelog -> stripelog. La BD se sigue llamando django_wow por historia (renombrarla es otra operación). Comprobado antes de tocar nada: 0 colisiones con nombres existentes, 0 palabras reservadas (contrastado contra las 260 de MySQL), sin vistas ni triggers que dependieran de ellas. El RENAME va en una sola sentencia porque así es atómico, y MySQL reapunta solo las 4 claves ajenas entre estas tablas. 170 referencias actualizadas en 37 ficheros. Se dejó a propósito sql/drop_home_securitytoken_authuser_fk.sql sin tocar: es una migración ya aplicada y reescribirla sería falsear el historial. De paso salió un fallo previo: prices.ts consultaba `home_restoreitemprice`, una tabla que NO existe. El try/catch de priceFrom se comía el error y devolvía siempre el precio por defecto, así que el precio de restaurar objetos nunca fue configurable. Se deja documentado en el código; crear la tabla es otra decisión. Verificado tras aplicar: 0 tablas home_, las 51 siguen ahí, y el conteo exacto de filas cuadra con el volcado previo (store_item 3068, item_data 44873, stripelog 35, store_order 26, noticia 50). La web responde 200 en todas las rutas y la portada carga las noticias sin errores. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+14
-14
@@ -7,18 +7,18 @@ export const PD_PER_UNIT = 100
|
||||
export const DP_MIN_AMOUNT = 1
|
||||
export const DP_MAX_AMOUNT = 200
|
||||
|
||||
/** Acredita PD (donate points) a una cuenta de juego en `home_api_points` (upsert). */
|
||||
/** Acredita PD (donate points) a una cuenta de juego en `api_points` (upsert). */
|
||||
export async function creditDPoints(accountId: number, points: number): Promise<boolean> {
|
||||
if (!accountId || !(points > 0)) return false
|
||||
try {
|
||||
const [rows] = await db(DB.default).query<RowDataPacket[]>(
|
||||
'SELECT id FROM home_api_points WHERE accountID = ?',
|
||||
'SELECT id FROM api_points WHERE accountID = ?',
|
||||
[accountId],
|
||||
)
|
||||
if (rows[0]) {
|
||||
await db(DB.default).query('UPDATE home_api_points SET dp = dp + ? WHERE accountID = ?', [points, accountId])
|
||||
await db(DB.default).query('UPDATE api_points SET dp = dp + ? WHERE accountID = ?', [points, accountId])
|
||||
} else {
|
||||
await db(DB.default).query('INSERT INTO home_api_points (accountID, vp, dp) VALUES (?, 0, ?)', [accountId, points])
|
||||
await db(DB.default).query('INSERT INTO api_points (accountID, vp, dp) VALUES (?, 0, ?)', [accountId, points])
|
||||
}
|
||||
return true
|
||||
} catch {
|
||||
@@ -31,7 +31,7 @@ export async function getDPointsBalance(accountId: number): Promise<number> {
|
||||
if (!accountId) return 0
|
||||
try {
|
||||
const [rows] = await db(DB.default).query<RowDataPacket[]>(
|
||||
'SELECT dp FROM home_api_points WHERE accountID = ?',
|
||||
'SELECT dp FROM api_points WHERE accountID = ?',
|
||||
[accountId],
|
||||
)
|
||||
return rows[0] ? Number(rows[0].dp) : 0
|
||||
@@ -45,7 +45,7 @@ export async function getVPointsBalance(accountId: number): Promise<number> {
|
||||
if (!accountId) return 0
|
||||
try {
|
||||
const [rows] = await db(DB.default).query<RowDataPacket[]>(
|
||||
'SELECT vp FROM home_api_points WHERE accountID = ?',
|
||||
'SELECT vp FROM api_points WHERE accountID = ?',
|
||||
[accountId],
|
||||
)
|
||||
return rows[0] ? Number(rows[0].vp) : 0
|
||||
@@ -59,7 +59,7 @@ export async function creditVPoints(accountId: number, points: number): Promise<
|
||||
if (!accountId || !(points > 0)) return false
|
||||
try {
|
||||
await db(DB.default).query(
|
||||
'INSERT INTO home_api_points (accountID, vp, dp) VALUES (?, ?, 0) ON DUPLICATE KEY UPDATE vp = vp + ?',
|
||||
'INSERT INTO api_points (accountID, vp, dp) VALUES (?, ?, 0) ON DUPLICATE KEY UPDATE vp = vp + ?',
|
||||
[accountId, points, points],
|
||||
)
|
||||
return true
|
||||
@@ -84,7 +84,7 @@ export async function spendVPoints(
|
||||
try {
|
||||
await conn.beginTransaction()
|
||||
const [src] = await conn.query<RowDataPacket[]>(
|
||||
'SELECT vp FROM home_api_points WHERE accountID = ? FOR UPDATE',
|
||||
'SELECT vp FROM api_points WHERE accountID = ? FOR UPDATE',
|
||||
[accountId],
|
||||
)
|
||||
const balance = src[0] ? Number(src[0].vp) : 0
|
||||
@@ -92,7 +92,7 @@ export async function spendVPoints(
|
||||
await conn.rollback()
|
||||
return { success: false, error: 'insufficientFunds' }
|
||||
}
|
||||
await conn.query('UPDATE home_api_points SET vp = vp - ? WHERE accountID = ?', [points, accountId])
|
||||
await conn.query('UPDATE api_points SET vp = vp - ? WHERE accountID = ?', [points, accountId])
|
||||
await conn.commit()
|
||||
return { success: true }
|
||||
} catch {
|
||||
@@ -126,7 +126,7 @@ export async function transferDPoints(
|
||||
await conn.beginTransaction()
|
||||
// Bloquea la fila del origen para evitar dobles gastos concurrentes.
|
||||
const [src] = await conn.query<RowDataPacket[]>(
|
||||
'SELECT dp FROM home_api_points WHERE accountID = ? FOR UPDATE',
|
||||
'SELECT dp FROM api_points WHERE accountID = ? FOR UPDATE',
|
||||
[fromAccountId],
|
||||
)
|
||||
const balance = src[0] ? Number(src[0].dp) : 0
|
||||
@@ -134,9 +134,9 @@ export async function transferDPoints(
|
||||
await conn.rollback()
|
||||
return { success: false, error: 'insufficientFunds' }
|
||||
}
|
||||
await conn.query('UPDATE home_api_points SET dp = dp - ? WHERE accountID = ?', [points, fromAccountId])
|
||||
await conn.query('UPDATE api_points SET dp = dp - ? WHERE accountID = ?', [points, fromAccountId])
|
||||
await conn.query(
|
||||
'INSERT INTO home_api_points (accountID, vp, dp) VALUES (?, 0, ?) ON DUPLICATE KEY UPDATE dp = dp + ?',
|
||||
'INSERT INTO api_points (accountID, vp, dp) VALUES (?, 0, ?) ON DUPLICATE KEY UPDATE dp = dp + ?',
|
||||
[toAccountId, points, points],
|
||||
)
|
||||
await conn.commit()
|
||||
@@ -170,7 +170,7 @@ export async function spendDPoints(
|
||||
try {
|
||||
await conn.beginTransaction()
|
||||
const [src] = await conn.query<RowDataPacket[]>(
|
||||
'SELECT dp FROM home_api_points WHERE accountID = ? FOR UPDATE',
|
||||
'SELECT dp FROM api_points WHERE accountID = ? FOR UPDATE',
|
||||
[accountId],
|
||||
)
|
||||
const balance = src[0] ? Number(src[0].dp) : 0
|
||||
@@ -178,7 +178,7 @@ export async function spendDPoints(
|
||||
await conn.rollback()
|
||||
return { success: false, error: 'insufficientFunds' }
|
||||
}
|
||||
await conn.query('UPDATE home_api_points SET dp = dp - ? WHERE accountID = ?', [points, accountId])
|
||||
await conn.query('UPDATE api_points SET dp = dp - ? WHERE accountID = ?', [points, accountId])
|
||||
await conn.commit()
|
||||
return { success: true }
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user