-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathmigration.mysql
More file actions
22 lines (20 loc) · 1.1 KB
/
Copy pathmigration.mysql
File metadata and controls
22 lines (20 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
INSERT INTO ilbot_channel (channel)
SELECT DISTINCT channel FROM irclog
WHERE channel LIKE '#%'
AND NOT EXISTS (SELECT * FROM ilbot_channel WHERE ilbot_channel.channel = irclog.channel);
INSERT INTO ilbot_day (channel, day)
SELECT DISTINCT ilbot_channel.id, irclog.day
FROM irclog
JOIN ilbot_channel ON ilbot_channel.channel = irclog.channel
LEFT JOIN ilbot_day ON ilbot_day.channel = ilbot_channel.id AND ilbot_day.day = irclog.day
WHERE irclog.channel LIKE '#%'
AND ilbot_day.id IS NULL;
INSERT INTO ilbot_lines (id, day,nick, timestamp, line, spam, in_summary)
SELECT irclog.id, ilbot_day.id, IF(irclog.nick = '', NULL, irclog.nick), irclog.timestamp, irclog.line, irclog.spam, irclog.in_summary
FROM irclog
JOIN ilbot_channel ON ilbot_channel.channel = irclog.channel
JOIN ilbot_day ON ilbot_day.channel = ilbot_channel.id AND ilbot_day.day = irclog.day
LEFT JOIN ilbot_lines ON ilbot_lines.id = irclog.id
WHERE irclog.channel LIKE '#%'
AND ilbot_lines.id IS NULL
ORDER BY irclog.id;