Refactor cape selection logic and remove trigger
Removed the 'unique_active_cape' database trigger and updated the showCape function to manually ensure only one cape is selected per player. This change centralizes the selection logic in application code for better maintainability and error handling.
This commit is contained in:
@@ -258,20 +258,6 @@ async function setupDatabase() {
|
||||
logger.log(`${"unique_active_skin".bold} trigger ready`, ["MariaDB", "yellow"])
|
||||
|
||||
await conn.query(`DROP TRIGGER IF EXISTS unique_active_cape`)
|
||||
await conn.query(`
|
||||
CREATE TRIGGER unique_active_cape
|
||||
AFTER UPDATE ON playersCapes
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.isSelected = 1 THEN
|
||||
UPDATE playersCapes
|
||||
SET isSelected = 0
|
||||
WHERE playerUuid = NEW.playerUuid
|
||||
AND id != NEW.id;
|
||||
END IF;
|
||||
END;
|
||||
`)
|
||||
logger.log(`${"unique_active_cape".bold} trigger ready`, ["MariaDB", "yellow"])
|
||||
|
||||
await conn.query(`DROP TRIGGER IF EXISTS auto_assign_random_default_skin`)
|
||||
await conn.query(`
|
||||
|
||||
Reference in New Issue
Block a user