/*
INSTRUCCIONES:
Cuándo se vaya a hacer una modificación en una base de datos, verificar si ya existe en este archivo alguna modificación. Si ya existe, las modificaciones se deben agregar luego del título
*/

/* attendances */
ALTER TABLE attendances ADD total BIGINT(20) DEFAULT 0;

/* birthday_messages */
CREATE TABLE birthday_messages (
    id BIGINT(20) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    body VARCHAR(500),
    status INT(1) DEFAULT 1,
    created_by BIGINT,
    created_at timestamp,
    updated_at timestamp
);

/* satellite_payment_files */
ALTER TABLE satellite_payment_files ADD payment_range VARCHAR(150) DEFAULT NULL;

/* contracts_has_contracts */
DROP TABLE IF EXISTS `contracts_has_contracts`;
CREATE TABLE `contracts_has_contracts` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `contract_id` int(11) DEFAULT NULL,
  `contract_type_id` int(11) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/* booking_schedules */
ALTER TABLE booking_schedules ADD old_sch_id INT(11) NOT NULL;
INSERT INTO `contracts_has_contracts` VALUES (1,8,0,NULL,NULL),(2,1,0,NULL,NULL),(3,7,0,NULL,NULL),(4,2,0,NULL,NULL),(5,11,0,NULL,NULL),(6,6,0,NULL,NULL),(8,10,0,NULL,NULL),(9,5,0,NULL,NULL),(10,3,0,NULL,NULL),(11,9,1,NULL,NULL),(12,4,0,NULL,NULL);

/* rooms_control_inventories */
ALTER TABLE `rooms_control_inventories` DROP INDEX `unique_item_per_room`;

DROP TABLE IF EXISTS `payroll_dian_numbers`;
CREATE TABLE `payroll_dian_numbers` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `payroll_id` int(11) DEFAULT NULL,
  `quarter` int(11) NOT NULL,
  `payment_satellite_id` int(11) DEFAULT NULL,
  `juice_service_id` int(11) DEFAULT NULL,
  `dian_number` int(11) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=549 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

------------------------------------------------------
---------------------EXTERNAL-------------------------
------------------------------------------------------
ALTER TABLE news ADD old_id INT(11) NOT NULL;

/* referred_models */
ALTER TABLE referred_models ADD tenant_creator_id BIGINT(20) DEFAULT NULL;

/* referred_model_shared */
ALTER TABLE referred_model_shared ADD tenant_id BIGINT(20) DEFAULT NULL;

/* referred_model_seen */
ALTER TABLE referred_model_seen ADD tenant_id BIGINT(20) DEFAULT NULL;

/* referred_models */
ALTER TABLE referred_models ADD cited INT(11) DEFAULT 0;

/* setting_page_tasks */
ALTER TABLE setting_page_tasks ADD old_id INT(11) DEFAULT NULL;

/* satellite_payment_pages */
ALTER TABLE satellite_payment_pages CHANGE setting_page_id setting_page_id BIGINT(20) UNSIGNED NULL;

/* satellite_payment_pages */
INSERT INTO satellite_payment_pages (name, type, cell_nick, cell_value, setting_page_id, has_euro, status, description, image, created_at, updated_at)
VALUES ('PagosGB', 'excel', '', '', NULL, '0', '0', NULL, NULL, '2021-06-25 10:43:31', '2021-06-25 10:43:31');

/* setting_page_task_reviews */
DROP TABLE IF EXISTS `setting_page_task_reviews`;
CREATE TABLE `setting_page_task_reviews` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `model_id` int(11) DEFAULT NULL, 
  `user_id` int(11) DEFAULT NULL,
  `task_id` int(11) DEFAULT NULL,
  `setting_page_id` int(11) DEFAULT NULL,
  `option_id` int(11) DEFAULT NULL,
  `date` date DEFAULT NULL, 
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=549 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `news` ADD `is_custom_birthday` BOOLEAN NULL DEFAULT FALSE AFTER `old_id`;