From 507075d9d44cfcd0f7e6d6284b4e729d12fca14b Mon Sep 17 00:00:00 2001 From: jellywx Date: Tue, 22 Jun 2021 16:46:42 +0100 Subject: [PATCH] fixed the migration script since mysql is stupid --- migration/reminder_message_embed.sql | 13 +++++++------ src/commands/reminder_cmds.rs | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/migration/reminder_message_embed.sql b/migration/reminder_message_embed.sql index ae27733..cf83610 100644 --- a/migration/reminder_message_embed.sql +++ b/migration/reminder_message_embed.sql @@ -48,15 +48,16 @@ CREATE TABLE reminders_new ( PRIMARY KEY (id), FOREIGN KEY (`channel_id`) REFERENCES channels (`id`) ON DELETE CASCADE, - FOREIGN KEY (`set_by`) REFERENCES users (`id`) ON DELETE SET NULL, + FOREIGN KEY (`set_by`) REFERENCES users (`id`) ON DELETE SET NULL # disallow having a reminder as restartable if it has no interval - CONSTRAINT restartable_interval_mutex CHECK (`restartable` = 0 OR `interval` IS NULL), + -- , CONSTRAINT restartable_interval_mutex CHECK (`restartable` = 0 OR `interval` IS NULL) # disallow disabling if interval is unspecified - CONSTRAINT interval_enabled_mutin CHECK (`enabled` = 1 OR `interval` IS NULL), + -- , CONSTRAINT interval_enabled_mutin CHECK (`enabled` = 1 OR `interval` IS NULL) # disallow an expiry time if interval is unspecified - CONSTRAINT interval_expires_mutin CHECK (`expires` IS NULL OR `interval` IS NOT NULL) -); + -- , CONSTRAINT interval_expires_mutin CHECK (`expires` IS NULL OR `interval` IS NOT NULL) +) +COLLATE utf8mb4_unicode_ci; # import data from other tables INSERT INTO reminders_new ( @@ -86,7 +87,7 @@ INSERT INTO reminders_new ( reminders.uid, reminders.name, reminders.channel_id, - FROM_UNIXTIME(reminders.time), + DATE_ADD(FROM_UNIXTIME(0), INTERVAL reminders.`time` SECOND), reminders.`interval`, reminders.enabled, reminders.expires, diff --git a/src/commands/reminder_cmds.rs b/src/commands/reminder_cmds.rs index 0a81a77..f3c8187 100644 --- a/src/commands/reminder_cmds.rs +++ b/src/commands/reminder_cmds.rs @@ -1675,8 +1675,8 @@ INSERT INTO reminders ( ?, ?, ?, - FROM_UNIXTIME(?), - FROM_UNIXTIME(?), + DATE_ADD(FROM_UNIXTIME(0), INTERVAL ? SECOND), + DATE_ADD(FROM_UNIXTIME(0), INTERVAL ? SECOND), ?, (SELECT id FROM users WHERE user = ? LIMIT 1) )