CREATE TABLE `device` (
  `device_id` INT NOT NULL AUTO_INCREMENT,
  `token` VARCHAR(45) NULL DEFAULT NULL,
  `user_id` INT(11) NULL,
  PRIMARY KEY (`device_id`),
  INDEX `users_idx` (`user_id` ASC),
  CONSTRAINT `users`
    FOREIGN KEY (`user_id`)
    REFERENCES `user` (`serial_usr`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);


ALTER TABLE `device` 
CHANGE COLUMN `token` `token` TEXT CHARACTER SET 'utf8' NULL DEFAULT NULL ,
ADD COLUMN `topic` TEXT NULL AFTER `user_id`;

