This repository was archived by the owner on Nov 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Database Migrations
sharedferret edited this page Apr 11, 2012
·
6 revisions
When the schema of this project's database is altered, the SQL statements necessary to update table structure to the newest version will be posted here.
###Migrate to users table: (1/26/12)
CREATE TABLE USERS (userid VARCHAR(255), username VARCHAR(255), lastseen DATETIME, PRIMARY KEY (userid, username));
INSERT INTO USERS (userid, username, lastseen) SELECT djid, djname, started FROM SONGLIST ORDER BY started asc ON DUPLICATE KEY UPDATE lastseen = SONGLIST.started;
INSERT INTO USERS (userid, username, lastseen) SELECT userid, user, time FROM CHATLOG ORDER BY time asc ON DUPLICATE KEY UPDATE lastseen = CHATLOG.time;
ALTER TABLE SONGLIST DROP COLUMN djname;
ALTER TABLE CHATLOG DROP COLUMN user;
###Migrate from epoch-based time to DATETIME: (12/26/11)
ALTER TABLE SONGLIST CHANGE COLUMN started temporary INT(11);
ALTER TABLE SONGLIST ADD COLUMN started DATETIME;
UPDATE SONGLIST SET started = FROM_UNIXTIME(temporary);
ALTER TABLE SONGLIST DROP COLUMN temporary;
ALTER TABLE CHATLOG ADD COLUMN time DATETIME;