2 DROP PROCEDURE IF EXISTS delete_inactive_users $$
3 CREATE PROCEDURE delete_inactive_users()
5 DECLARE deadlock INT DEFAULT 0;
6 DECLARE attempts INT DEFAULT 0;
7 DECLARE done INT DEFAULT 0;
8 DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
10 try_loop:WHILE (attempts<3) DO
12 DECLARE deadlock_detected CONDITION FOR 1213;
13 DECLARE EXIT HANDLER FOR deadlock_detected
22 delete from auth_user where is_active=0 and datediff(date(now()), date(date_joined)) > 7;
29 SET attempts=attempts+1;
34 call FAIL('Inactive users are not deleted!');
40 DROP TABLE IF EXISTS `sanitizing_rules`;
41 CREATE TABLE `sanitizing_rules` (
42 `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
43 `use_podcast` bool NOT NULL,
44 `use_episode` bool NOT NULL,
45 `search` varchar(100) NOT NULL,
46 `replace` varchar(100) NOT NULL,
47 `priority` integer UNSIGNED NOT NULL,
48 `description` longtext NOT NULL
51 alter table subscription add column id int unique auto_increment;
53 create unique index unique_subscription_meta on subscription (user_id, podcast_id);
55 create unique index unique_device_user_uid on device (user_id, uid);
57 alter table subscription_log change timestamp timestamp datetime not null;
58 alter table episode_log change timestamp timestamp datetime not null;