Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions SQL/feedback_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,63 @@ CREATE TABLE IF NOT EXISTS `chatlogs_logs` (
KEY `chatlogs_ckeys_FK` (`target`),
CONSTRAINT `chatlogs_ckeys_FK` FOREIGN KEY (`target`) REFERENCES `chatlogs_ckeys` (`ckey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
<<<<<<< HEAD
=======

-- If you are doing this with the cli you will have to tell it first to use something else as a delimiter instead of ;
-- Otherwise the copy/paste will fail. Do not forget to revert the change in the end.
DELIMITER //
CREATE EVENT `chatlogs_logs_clear_old_logs`
ON SCHEDULE
EVERY 1 MONTH STARTS '2025-01-01 04:00:00'
ON COMPLETION PRESERVE
ENABLE
COMMENT 'This event periodically clears the chatlog logs of very old logs'
DO BEGIN

DELETE FROM chatlogs_logs WHERE created_at < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 3 MONTH)) * 1000;

END
DELIMITER ;
-- Also enable the event_scheduler after creating the event
SET GLOBAL event_scheduler = ON;

-- Table structure for table `chatlogs_rounds`
CREATE TABLE `chatlogs_rounds` (
`round_id` BIGINT(20) NOT NULL DEFAULT -1,
`ckey` VARCHAR(45) NOT NULL COLLATE 'utf8mb4_uca1400_ai_ci',
PRIMARY KEY (`round_id`, `ckey`) USING BTREE
) ENGINE=InnoDB COLLATE='utf8mb4_uca1400_ai_ci';

-- If you are doing this with the cli you will have to tell it first to use something else as a delimiter instead of ;
-- Otherwise the copy/paste will fail. Do not forget to revert the change in the end.
DELIMITER //
CREATE PROCEDURE `chatlogs_rounds_insert`(
IN `p_round_id` BIGINT,
IN `p_ckey` VARCHAR(45)
)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY INVOKER
COMMENT 'Inserts a new row into \'chatlogs_rounds\' and deletes the oldest entry, if the ckey already has 10 round id\'s stored.'
BEGIN

INSERT IGNORE INTO chatlogs_rounds(round_id, ckey) VALUES (p_round_id, p_ckey);

IF (SELECT COUNT(*) FROM chatlogs_rounds WHERE ckey = p_ckey) > 10 THEN
DELETE FROM chatlogs_rounds WHERE ckey = p_ckey ORDER BY round_id ASC LIMIT 1;
END IF;

END
DELIMITER ;

-- CHOMPedit Start
CREATE TABLE IF NOT EXISTS `erro_mentor` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ckey` varchar(32) NOT NULL,
`mentor` int(16) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;
-- CHOMPedit End
>>>>>>> 33fc470bfa (Gets rid of unneeded schema (#11766))
Loading