DELIMITER //

DROP DATABASE IF EXISTS `test_db`;
CREATE DATABASE `test_db`;

use test_db;

DROP TABLE IF EXISTS `Token`;
CREATE TABLE `Token` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `username` varchar(20) NOT NULL,
  `time_end` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;


SET GLOBAL event_scheduler = ON;
DROP EVENT IF EXISTS fooEvent;
CREATE EVENT fooEvent
ON SCHEDULE EVERY 1 DAY
DO
    DELETE FROM Token WHERE DATE(time_end) < CURRENT_DATE;

DROP PROCEDURE IF EXISTS foo1;
CREATE PROCEDURE foo1() BEGIN
	SELECT * FROM Token;
END //

DROP PROCEDURE IF EXISTS foo2;
CREATE PROCEDURE foo2() BEGIN
	SELECT * FROM Token;
END //

