INSERT INTO `permissions` (`id`, `name`, `display_name`, `sort`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (NULL, 'view-document-report', 'View Document Report', '33', '1', '1', NULL, '2023-11-06 23:02:21', '2023-11-06 23:02:21', NULL);
INSERT INTO `permission_role` (`id`, `permission_id`, `role_id`) VALUES (NULL, '33', '1');
INSERT INTO `permission_user` (`id`, `permission_id`, `user_id`) VALUES (NULL, '33', '3');

INSERT INTO `permissions` (`id`, `name`, `display_name`, `sort`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (NULL, 'add-permission', 'Add Permission in Tree View', '34', '1', '1', NULL, '2023-11-07 00:02:21', '2023-11-07 00:02:21', NULL);
INSERT INTO `permission_user` (`id`, `permission_id`, `user_id`) VALUES (NULL, '34', '3');

INSERT INTO `permissions` (`id`, `name`, `display_name`, `sort`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (NULL, 'show-permission', 'Show Permission in Tree View', '35', '1', '1', NULL, '2023-11-07 00:02:21', '2023-11-07 00:02:21', NULL);
INSERT INTO `permission_user` (`id`, `permission_id`, `user_id`) VALUES (NULL, '35', '3');

INSERT INTO `categories` (`id`, `name`, `parent_category_id`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (NULL, 'root', NULL, '1', NULL, '2023-11-16 15:41:52', '2023-11-16 15:41:52', NULL);
INSERT INTO `category_user` (`id`, `category_id`, `user_id`, `created_at`, `updated_at`) VALUES (NULL, '25491', '1', NULL, NULL);

UPDATE `categories` SET `parent_category_id`= 25491 WHERE `parent_category_id` IS NULL AND `name` != "root";

ALTER TABLE `documents` ADD `file_type` varchar(255) DEFAULT NULL AFTER `file_name`;


INSERT INTO `permission_role` (`id`, `permission_id`, `role_id`) VALUES (NULL, '34', '1');
INSERT INTO `permission_role` (`id`, `permission_id`, `role_id`) VALUES (NULL, '35', '1');
INSERT INTO `permission_role` (`id`, `permission_id`, `role_id`) VALUES (NULL, '36', '1');

INSERT INTO `permissions` (`id`, `name`, `display_name`, `sort`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (NULL, 'view-log', 'View Log ', '37', '1', '1', NULL, '2023-11-06 23:02:21', '2023-11-06 23:02:21', NULL);
INSERT INTO `permission_role` (`id`, `permission_id`, `role_id`) VALUES (NULL, '37', '1');

INSERT INTO `permissions` (`id`, `name`, `display_name`, `sort`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (NULL, 'view-log-filter', 'View Log Filter', '38', '1', '1', NULL, '2023-11-06 23:02:21', '2023-11-06 23:02:21', NULL);
INSERT INTO `permission_role` (`id`, `permission_id`, `role_id`) VALUES (NULL, '38', '1');

ALTER TABLE `category_user`
ADD COLUMN `permissions` INT NOT NULL DEFAULT 0;

INSERT INTO `permissions` (`id`, `name`, `display_name`, `sort`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (NULL, 'add-permission-document', 'Add Permission on Document', '42', '1', '1', NULL, '2023-11-07 00:02:21', '2023-11-07 00:02:21', NULL);
INSERT INTO `permission_user` (`id`, `permission_id`, `user_id`) VALUES (NULL, '43', '1');
INSERT INTO `permissions` (`id`, `name`, `display_name`, `sort`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (NULL, 'show-permission-document', 'Show Permission Document', '43', '1', '1', NULL, '2023-11-07 00:02:21', '2023-11-07 00:02:21', NULL);
INSERT INTO `permission_user` (`id`, `permission_id`, `user_id`) VALUES (NULL, '44', '1');

UPDATE category_user SET permissions = '7' WHERE category_id = 25491 AND user_id = 1;

ALTER TABLE `categories`
ADD COLUMN  `serial_number` varchar(191) DEFAULT NULL AFTER `name`,
ADD COLUMN  `url` varchar(191) DEFAULT NULL AFTER `serial_number`;

DROP TABLE `documents`;
DROP TABLE `document_user`;

DELETE FROM `permissions` WHERE `id` = 24 OR `name`='view-category';
DELETE FROM `permissions` WHERE `id` = 25 OR `name`='create-category';
DELETE FROM `permissions` WHERE `id` = 26 OR `name`='edit-category';
DELETE FROM `permissions` WHERE `id` = 27 OR `name`='delete-category';

DELETE FROM `permissions` WHERE `id` = 29 OR `name`='view-document';
DELETE FROM `permissions` WHERE `id` = 30 OR `name`='create-document';
DELETE FROM `permissions` WHERE `id` = 31 OR `name`='edit-document';
DELETE FROM `permissions` WHERE `id` = 32 OR `name`='delete-document';

INSERT INTO `permission_role` (`id`, `permission_id`, `role_id`) VALUES (NULL, '43', '1');
INSERT INTO `permission_role` (`id`, `permission_id`, `role_id`) VALUES (NULL, '44', '1');

ALTER TABLE `logs`
ADD COLUMN  `updated_at` timestamp NULL DEFAULT NULL AFTER `created_at`;

UPDATE `category_user` SET `permissions` = '15' WHERE `user_id` = 1 AND `category_id`=25491;


DELETE FROM `permissions` WHERE `name`='view-backend';
DELETE FROM `permissions` WHERE `name`='view-frontend';
DELETE FROM `permissions` WHERE `name`='view-access-management';
DELETE FROM `permissions` WHERE `name`='clear-user-session';
DELETE FROM `permissions` WHERE `name`='login-as-user';
DELETE FROM `permissions` WHERE `name`='edit-settings';
DELETE FROM `permissions` WHERE `name`='view-log';


UPDATE `roles` SET `name` = 'Root' WHERE `roles`.`id` = 1;

INSERT INTO `permissions` (`id`, `name`, `display_name`, `sort`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (NULL, 'view-category', 'View Document Management', '37', '1', '1', NULL, '2023-11-06 23:02:21', '2023-11-06 23:02:21', NULL);
INSERT INTO `permission_role` (`id`, `permission_id`, `role_id`) VALUES (NULL, '37', '1');
INSERT INTO `roles` (`id`, `name`, `all`, `sort`, `status`, `created_by`, `updated_by`, `created_at`, `updated_at`, `deleted_at`) VALUES (NULL, 'Admin', '0', '2', '1', '1', NULL, '2023-11-07 00:02:21', '2023-11-07 00:02:21', NULL);

ALTER TABLE `categories`
ADD COLUMN  `size` varchar(191) DEFAULT NULL AFTER `url`,
ADD COLUMN  `size_s3` varchar(191) DEFAULT NULL AFTER `size`;

ALTER TABLE `categories`
ADD COLUMN  `expire_date` varchar(191) DEFAULT NULL AFTER `size_s3`;
