--
-- Drop table `ads`
--

DROP TABLE `ads`;

--
-- New table `cache`
--

CREATE TABLE `cache` (
  `key` varchar(255) NOT NULL,
  `value` mediumtext NOT NULL,
  `expiration` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `cache`
    ADD PRIMARY KEY (`key`);
COMMIT;

--
-- New table `cache_locks`
--

CREATE TABLE `cache_locks` (
  `key` varchar(255) NOT NULL,
  `owner` varchar(255) NOT NULL,
  `expiration` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `cache_locks`
    ADD PRIMARY KEY (`key`);
COMMIT;


--
-- New table column in `files`
--

ALTER TABLE `files` ADD `short_key` VARCHAR(250) AFTER `disk`;

--
-- New table `file_affiliate`
--

CREATE TABLE `file_affiliate` LIKE `file_analytics`; 
INSERT INTO `file_affiliate` SELECT * FROM `file_analytics`;

--
-- Drop table column in `file_analytics`
--

ALTER TABLE `file_analytics` DROP COLUMN `additional`;

--
-- New table `sessions`
--

CREATE TABLE `sessions` (
  `id` varchar(255) NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `payload` longtext NOT NULL,
  `last_activity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `sessions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sessions_user_id_index` (`user_id`),
  ADD KEY `sessions_last_activity_index` (`last_activity`);
COMMIT;

--
-- New table `settings_affiliate`
--

CREATE TABLE `settings_affiliate` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `created_by_id` int(11) NOT NULL,
  `created_by_ip` varchar(45) NOT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `updated_by_id` int(11) NOT NULL,
  `updated_by_ip` varchar(45) NOT NULL,
  `name` varchar(250) NOT NULL,
  `value` mediumtext DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `settings_affiliate` (`id`, `created_at`, `created_by_id`, `created_by_ip`, `updated_at`, `updated_by_id`, `updated_by_ip`, `name`, `value`) VALUES
(1, CURRENT_TIMESTAMP(), 1, '192.168.1.1', CURRENT_TIMESTAMP(), 1, '192.168.1.1', 'status', '1'),
(2, CURRENT_TIMESTAMP(), 1, '192.168.1.1', CURRENT_TIMESTAMP(), 1, '192.168.1.1', 'type', '1');

ALTER TABLE `settings_affiliate`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `settings_affiliate`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
COMMIT;

--
-- New table `settings_download`
--

CREATE TABLE `settings_download` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `created_by_id` int(11) NOT NULL,
  `created_by_ip` varchar(45) NOT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `updated_by_id` int(11) NOT NULL,
  `updated_by_ip` varchar(45) NOT NULL,
  `name` varchar(250) NOT NULL,
  `value` mediumtext DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `settings_download` (`id`, `created_at`, `created_by_id`, `created_by_ip`, `updated_at`, `updated_by_id`, `updated_by_ip`, `name`, `value`) VALUES
(1, CURRENT_TIMESTAMP(), 1, '192.168.1.1', CURRENT_TIMESTAMP(), 1, '192.168.1.1', 'countdown', '15'),
(2, CURRENT_TIMESTAMP(), 1, '192.168.1.1', CURRENT_TIMESTAMP(), 1, '192.168.1.1', 'adblock_blocker', '1'),
(3, CURRENT_TIMESTAMP(), 1, '192.168.1.1', CURRENT_TIMESTAMP(), 1, '192.168.1.1', 'top_area', '<div class=\"text-center\">\r\n<img src=\"https://portus.aneontech.com/assets/image/ad-top.webp\" width=\"728\" height=\"90\" class=\"mw-100\" alt=\"Ad image\">\r\n</div>'),
(4, CURRENT_TIMESTAMP(), 1, '192.168.1.1', CURRENT_TIMESTAMP(), 1, '192.168.1.1', 'middle_area', '<div class=\"text-center\">\r\n<img src=\"https://portus.aneontech.com/assets/image/ad-middle.webp\" width=\"728\" height=\"90\" class=\"mw-100\" alt=\"Ad image\">\r\n</div>'),
(5, CURRENT_TIMESTAMP(), 1, '192.168.1.1', CURRENT_TIMESTAMP(), 1, '192.168.1.1', 'bottom_area', '<div class=\"text-center\">\r\n<img src=\"https://portus.aneontech.com/assets/image/ad-bottom.webp\" width=\"728\" height=\"90\" class=\"mw-100\" alt=\"Ad image\">\r\n</div>'),
(6, CURRENT_TIMESTAMP(), 1, '192.168.1.1', CURRENT_TIMESTAMP(), 1, '192.168.1.1', 'js_codes', NULL);

ALTER TABLE `settings_download`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `settings_download`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
COMMIT;

--
-- New data for table `settings_storage`
--

INSERT INTO `settings_storage` (`created_at`, `created_by_id`, `created_by_ip`, `updated_at`, `updated_by_id`, `updated_by_ip`, `name`, `value`, `storage_key`, `default`) VALUES
(CURRENT_TIMESTAMP(), 1, '192.168.1.1', CURRENT_TIMESTAMP(), 1, '192.168.1.1', 'Google Drive', '{\"client_id\":\"\",\"client_secret\":\"\",\"refresh_token\":\"\",\"folder\":null}', 'google', NULL);
