SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

ALTER TABLE `categories` 
ADD COLUMN `users_id` INT(11) NOT NULL DEFAULT 1 AFTER `iconClass`,
ADD COLUMN `private` TINYINT(1) NULL DEFAULT 0 AFTER `users_id`,
ADD INDEX `fk_categories_users1_idx` (`users_id` ASC);

ALTER TABLE `categories` 
ADD CONSTRAINT `fk_categories_users1`
  FOREIGN KEY (`users_id`)
  REFERENCES `users` (`id`)
  ON DELETE CASCADE
  ON UPDATE CASCADE;


UPDATE configurations SET  version = '6.2', modified = now() WHERE id = 1;

SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
