-- Note: This file contains SQL statements for migrating between versions.
-- You should _not_ run all of them.  Depending on what you are upgrading
-- from/to, choose the appropriate statements from this file and run them
-- manually.  For instance, you could copy/paste them into an interactive
-- MariaDB prompt.

-- Migration from v1 to v2 --
ALTER TABLE users ADD COLUMN email_inter INT DEFAULT 30;
ALTER TABLE users ADD COLUMN email_range VARCHAR(30) DEFAULT '';
ALTER TABLE users ADD COLUMN ts_email TIMESTAMP DEFAULT '2000-01-01 00:00:00';
ALTER TABLE notifs ADD COLUMN subspace INT;
ALTER TABLE notifs ADD COLUMN is_hidden BOOLEAN DEFAULT FALSE;
ALTER TABLE notifs ADD INDEX (dst,post);
ALTER TABLE notifs DROP INDEX type;

-- Migration from v2 to v3 --
ALTER TABLE posts ADD COLUMN num_people INT DEFAULT 0;
ALTER TABLE posts ADD COLUMN ts_comment TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE likes ADD INDEX (post);

-- Migration from v3 to v4 --
ALTER TABLE follow ADD INDEX (user);
ALTER TABLE posts ADD INDEX (subspace);
ALTER TABLE posts ADD INDEX (parent);
ALTER TABLE posts ADD INDEX (user);
ALTER TABLE posts ADD INDEX (issueid);

-- Migration from v4 to v5 --
ALTER TABLE users ADD COLUMN timezone VARCHAR(40) DEFAULT 'UTC';
ALTER TABLE users ADD COLUMN recovery VARCHAR(1000) DEFAULT '';
ALTER TABLE notifs ADD COLUMN comment INT;

-- Migration from v6.11 to v6.12 --
ALTER TABLE users MODIFY COLUMN notif INT DEFAULT 0xffffff;
UPDATE users SET notif=notif|0x040000;

-- Migration from v6 to v7 --
UPDATE users SET notif=notif|0x100000;

-- Migration from v7 to v8 --
ALTER TABLE users ADD COLUMN flair VARCHAR(30) DEFAULT '';

-- Migration from v8.0 to v8.1 --
ALTER TABLE users MODIFY COLUMN flair VARCHAR(1000) DEFAULT '';

-- Migration from v9.9 to v9.10 --
ALTER TABLE users ADD COLUMN ts_cleanup TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
