INSERT INTO `myemergency_possible_rights` (`fromsystem`, `right_key`, `sortorder`) VALUES 
('medic','licenses.view',16000),
('medic','licenses.edit',16010),
('medic','licenses.delete',16020),
('police','notes.edit',17000),
('police','notes.delete',17010),
('medic','notes.edit',17000),
('medic','notes.delete',17010)
on duplicate key update `sortorder` = VALUES(`sortorder`)
;

ALTER TABLE `myemergency_law_books` 
ADD COLUMN `deleted` TINYINT(1) NOT NULL DEFAULT 0;

ALTER TABLE `myemergency_law_book_laws` 
ADD COLUMN `deleted` TINYINT(1) NOT NULL DEFAULT 0;

CREATE TABLE `myemergency_files_entries_laws_relation` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fromsystem` varchar(50) NOT NULL DEFAULT 'police',
  `file_entry_id` varchar(90) NOT NULL DEFAULT '',
  `lawbook_law_id` INT  NOT NULL DEFAULT 0,
  `amount` INT  NOT NULL DEFAULT 0,
  `historized_minimum_penalty` INT  NOT NULL DEFAULT 0,
  `historized_detention_time` INT  NOT NULL DEFAULT 0,
  `createdby` varchar(90) NOT NULL DEFAULT '',
  `createddate` timestamp NOT NULL DEFAULT current_timestamp(),
  `changedby` varchar(90) NOT NULL DEFAULT '',
  `changeddate` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_file_entry_id` (`file_entry_id`)
);


-- for update 2.1.7
CREATE TABLE `mymdt_evidencerooms` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fromsystem` VARCHAR(50) NOT NULL DEFAULT 'police',
  `name` varchar(90) NOT NULL DEFAULT '',
  `createdby` varchar(90) NOT NULL DEFAULT '',
  `createddate` timestamp NOT NULL DEFAULT current_timestamp,
  `changedby` varchar(90) NOT NULL DEFAULT '',
  `changeddate` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE current_timestamp,
  PRIMARY KEY (`id`),
  KEY `idx_name` (`name`)
);

CREATE TABLE `mymdt_evidenceroom_articles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `evidenceroom_id` int(11) NOT NULL DEFAULT 0,
  `fromsystem` varchar(50) NOT NULL DEFAULT 'police',
  `file_id` varchar(90) NOT NULL,
  `name` varchar(90) NOT NULL DEFAULT '',
  `amount` int NOT NULL DEFAULT 0,
  `state` int NOT NULL DEFAULT 0,
  `others` text DEFAULT NULL,
  `createdby` varchar(90) NOT NULL DEFAULT '',
  `createddate` timestamp NOT NULL DEFAULT current_timestamp(),
  `changedby` varchar(90) NOT NULL DEFAULT '',
  `changeddate` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_evidenceroom_id` (`evidenceroom_id`),
  KEY `idx_state` (`state`)
);

INSERT INTO `myemergency_possible_rights` (`fromsystem`, `right_key`, `sortorder`) VALUES 
('police','evidencerooms.view',18000),
('police','evidencerooms.edit',18010),
('police','evidencerooms.delete',18020)
on duplicate key update `sortorder` = VALUES(`sortorder`);


-- for update 2.1.8
INSERT INTO `myemergency_possible_rights` (`fromsystem`, `right_key`, `sortorder`) VALUES 
('police','prison.view',19000)
on duplicate key update `sortorder` = VALUES(`sortorder`);



