/*direct_messages*/
ALTER TABLE `direct_messages` MODIFY COLUMN `inbox` BIGINT(20) NOT NULL DEFAULT 0,
 MODIFY COLUMN `sent` BIGINT(20) NOT NULL DEFAULT 0,
 ADD INDEX `idx_direct_messages_1`(`recipientId`),
 ADD INDEX `idx_direct_messages_2`(`senderId`);
UPDATE direct_messages SET inbox = UNIX_TIMESTAMP() * 1000 WHERE inbox = 0;
UPDATE direct_messages SET sent = UNIX_TIMESTAMP() * 1000 WHERE sent = 0;
UPDATE direct_messages SET inbox = 0 WHERE inbox=1;
UPDATE direct_messages SET sent=0 WHERE sent=1;
/*favorites*/
ALTER TABLE `favorites` MODIFY COLUMN `createdTime` BIGINT(20) NOT NULL DEFAULT 0,
 ADD COLUMN `removedTime` BIGINT(20) NOT NULL DEFAULT 0 AFTER `createdTime`;
/*friendships*/
ALTER TABLE `friendships` ADD COLUMN `createdTime` BIGINT(20) NOT NULL DEFAULT 0 AFTER `notify`,
 ADD COLUMN `removedTime` BIGINT(20) NOT NULL DEFAULT 0 AFTER `createdTime`,
 ADD COLUMN `accept` TINYINT(1) NOT NULL DEFAULT 0 AFTER `removedTime`,
 DROP INDEX `idx_friendships_1`,
 ADD UNIQUE INDEX `idx_friendships_1` USING BTREE(`activeId`, `passiveId`, `removedTime`);
UPDATE friendships AS a,
       friendships AS b
SET a.accept = true,
    b.accept = true
WHERE a.activeId = b.passiveId AND
      a.passiveId = b.activeId;
/*statuses*/
ALTER TABLE `statuses` CHANGE COLUMN `remove` `removedTime` BIGINT(20) NOT NULL DEFAULT 0;
UPDATE statuses SET removedTime = UNIX_TIMESTAMP() * 1000 WHERE removedTime = 1;
/*users*/
ALTER TABLE `users` DROP COLUMN `following`,
 DROP COLUMN `followers`,
 ADD COLUMN `protect` TINYINT(1) NOT NULL DEFAULT 0 AFTER `replies`,
 ADD COLUMN `creatorId` BIGINT(20) NOT NULL DEFAULT 0 AFTER `protect`,
 ADD COLUMN `modifierId` BIGINT(20) NOT NULL DEFAULT 0 AFTER `creatorId`,
 DROP INDEX `idx_users_1`,
 ADD UNIQUE INDEX `idx_users_1` USING BTREE(`foreignKey`, `serverFileId`);
