Add composite primary key to player_capes and update messages

Added a composite primary key (playerUuid, assetHash) to the player_capes table for better data integrity. Updated userRepository.js to use English messages for cape assignment and removal operations.
This commit is contained in:
2026-01-18 23:16:11 +01:00
parent 0049ae8ec6
commit 01e0b94d35
3 changed files with 10 additions and 6 deletions

View File

@@ -229,6 +229,7 @@ async function setupDatabase() {
assetHash VARCHAR(64) NOT NULL,
isSelected TINYINT(1) DEFAULT 0,
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (playerUuid, assetHash),
FOREIGN KEY (playerUuid) REFERENCES players(uuid) ON DELETE CASCADE,
FOREIGN KEY (assetHash) REFERENCES textures(hash) ON DELETE CASCADE
)

View File

@@ -63,6 +63,9 @@ function getUrlParam(url, param) {
}
function handleDBError(error, errorMessage = "Internal Server Error", code = 500) {
if (error instanceof DefaultError) {
throw error
}
logger.log(errorMessage.bold + " : " + error.toString(), ["MariaDB", "yellow"])
throw new DefaultError(code, errorMessage, "InternalServerError")
}