MySQL-run on a daily basis, MySQL-run
Design the script executed at a specified point every day during the recent project, so Mark it here to facilitate searching
Set time_zone = '+ 8:00 ';
Set GLOBAL event_scheduler = 1;
-- Set the database base database to which the event is used or belongs
Use nitrogenates;
# Delete a task scheduler with the same name first
Drop event if exists upload_to_sdmp;
# Set the separator to '$' and mysql's default statement separator to ';'. In this way, the code from create to end will be executed as a statement.
DELIMITER $
# Create a scheduled task, set the first execution time to '2017-07-30 10:00:00 ', and run the task once a day
Create event upload_to_sdmp
On schedule every 1 day starts timestamp '2017-01-17 07:16:00'
# On schedule every 1 SECOND
Do
# What to do to start the scheduled task
Begin
-- Do something: compile your scheduled tasks
# INSERT test_group (name, project_id) VALUES ("haha", 1 );
# Obtain the last executed Case_ALL and copy it to the new ID
# Change the time to the current time
# Change the ID of the last executed Case to a new ID.
Insert into execution (name, project_id, test_suite_id) select name, project_id, test_suite_id from execution WHERE test_suite_id = 3 order by created_time desc limit 1;
UPDATE execution SET created_time = (select CURRENT_TIMESTAMP) WHERE created_time = "0000-00-00 00:00:00 ";
# UPDATE queue_entry SET execution_id = (SELECT id FROM execution order by id desc limit 1) WHERE execution_id = (select id from execution WHERE test_suite_id = 3 order by created_time desc limit 1, 1 );
Insert into queue_entry (test_case_id, project_id) select test_case_id, project_id from queue_entry WHERE execution_id = (select id from execution WHERE test_suite_id = 3 order by created_time desc limit 1, 1 );
UPDATE queue_entry SET execution_id = (SELECT id FROM execution order by id desc limit 1) WHERE execution_id = 0;
# Obtain the second to last
# Select id from execution WHERE test_suite_id = 3 order by created_time desc limit 1, 1;
# Latest ID
# SELECT id FROM execution order by id desc limit 1;
-- End a scheduled task
End $
# Set the statement delimiter back ';'
DELIMITER;