fixed the migration script since mysql is stupid

This commit is contained in:
jellywx 2021-06-22 16:46:42 +01:00
parent 85659f05aa
commit 507075d9d4
2 changed files with 9 additions and 8 deletions

View File

@ -48,15 +48,16 @@ CREATE TABLE reminders_new (
PRIMARY KEY (id), PRIMARY KEY (id),
FOREIGN KEY (`channel_id`) REFERENCES channels (`id`) ON DELETE CASCADE, 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 # 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 # 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 # 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 # import data from other tables
INSERT INTO reminders_new ( INSERT INTO reminders_new (
@ -86,7 +87,7 @@ INSERT INTO reminders_new (
reminders.uid, reminders.uid,
reminders.name, reminders.name,
reminders.channel_id, reminders.channel_id,
FROM_UNIXTIME(reminders.time), DATE_ADD(FROM_UNIXTIME(0), INTERVAL reminders.`time` SECOND),
reminders.`interval`, reminders.`interval`,
reminders.enabled, reminders.enabled,
reminders.expires, reminders.expires,

View File

@ -1675,8 +1675,8 @@ INSERT INTO reminders (
?, ?,
?, ?,
?, ?,
FROM_UNIXTIME(?), DATE_ADD(FROM_UNIXTIME(0), INTERVAL ? SECOND),
FROM_UNIXTIME(?), DATE_ADD(FROM_UNIXTIME(0), INTERVAL ? SECOND),
?, ?,
(SELECT id FROM users WHERE user = ? LIMIT 1) (SELECT id FROM users WHERE user = ? LIMIT 1)
) )