--- 2-8-2022----

-- Adminer 4.8.1 MySQL 5.5.5-10.4.22-MariaDB dump

SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

CREATE TABLE `activities` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `url` text NOT NULL,
  `data` text DEFAULT NULL,
  `client` int(11) DEFAULT NULL,
  `admin` int(11) DEFAULT NULL,
  `ip` varchar(100) DEFAULT NULL,
  `device` varchar(255) DEFAULT NULL,
  `browser` varchar(255) DEFAULT NULL,
  `created` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `admin` (`admin`),
  KEY `client` (`client`),
  CONSTRAINT `activities_ibfk_1` FOREIGN KEY (`admin`) REFERENCES `admins` (`id`) ON DELETE CASCADE,
  CONSTRAINT `activities_ibfk_2` FOREIGN KEY (`client`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



-- Adminer 4.8.1 MySQL 5.5.5-10.4.22-MariaDB dump

SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';

CREATE TABLE `users_tokens` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `admin_id` int(11) DEFAULT NULL,
  `token` varchar(200) NOT NULL,
  `device_id` varchar(255) DEFAULT NULL,
  `device_type` enum('android','ios','web') DEFAULT NULL,
  `device_name` varchar(255) DEFAULT NULL,
  `fcm_token` text DEFAULT NULL,
  `expire_on` datetime NOT NULL,
  `created` datetime NOT NULL,
  `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `admin_id` (`admin_id`),
  CONSTRAINT `users_tokens_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `users_tokens_ibfk_2` FOREIGN KEY (`admin_id`) REFERENCES `admins` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


ALTER TABLE `users`
CHANGE `expire_otp` `expire_otp` datetime NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `otp`,
ADD `deleted_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `expire_otp`,
CHANGE `created_at` `created_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP AFTER `deleted_at`;

ALTER TABLE `users`
CHANGE `expire_otp` `expire_otp` datetime NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `otp`,
ADD `device_id` varchar(255) NULL AFTER `expire_otp`,
ADD `device_type` varchar(255) NULL AFTER `device_id`,
ADD `device_name` varchar(255) NULL AFTER `device_type`,
ADD `fcm_token` varchar(255) NULL AFTER `device_name`,
CHANGE `deleted_at` `deleted_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `fcm_token`,
CHANGE `created_at` `created_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP AFTER `deleted_at`;


ALTER TABLE `users`
CHANGE `expire_otp` `expire_otp` datetime NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `otp`,
ADD `token` varchar(255) COLLATE 'utf8mb4_unicode_ci' NULL AFTER `fcm_token`,
ADD `verified_at` datetime NULL AFTER `token`,
ADD `last_login` datetime NULL AFTER `verified_at`,
CHANGE `deleted_at` `deleted_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `last_login`,
CHANGE `created_at` `created_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP AFTER `deleted_at`;


ALTER TABLE `users`
CHANGE `expire_otp` `expire_otp` datetime NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `otp`,
CHANGE `token` `token` text COLLATE 'utf8mb4_unicode_ci' NULL AFTER `fcm_token`,
CHANGE `deleted_at` `deleted_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `last_login`,
CHANGE `created_at` `created_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP AFTER `deleted_at`;


ALTER TABLE `users`
CHANGE `expire_otp` `expire_otp` datetime NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `otp`,
ADD `created_by` int(11) NULL AFTER `token`,
CHANGE `deleted_at` `deleted_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `last_login`,
CHANGE `created_at` `created_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP AFTER `deleted_at`,
ADD `created` datetime NULL,
ADD `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`,
ADD FOREIGN KEY (`created_by`) REFERENCES `admins` (`id`) ON DELETE CASCADE;


ALTER TABLE `addresses`
CHANGE `updated_at` `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created_at`,
ADD `created` datetime NULL ON UPDATE CURRENT_TIMESTAMP,
ADD `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;


ALTER TABLE `users`
CHANGE `status` `status` tinyint(4) NULL DEFAULT '1' AFTER `remember_token`,
CHANGE `expire_otp` `expire_otp` datetime NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `otp`,
CHANGE `deleted_at` `deleted_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `last_login`,
CHANGE `created_at` `created_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP AFTER `deleted_at`,
CHANGE `modified` `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

ALTER TABLE `users`
CHANGE `expire_otp` `expire_otp` datetime NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `otp`,
CHANGE `deleted_at` `deleted_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP AFTER `last_login`,
CHANGE `created_at` `created_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP AFTER `deleted_at`,
CHANGE `modified` `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

ALTER TABLE `users`
CHANGE `expire_otp` `expire_otp` datetime NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `otp`,
CHANGE `deleted_at` `deleted_at` timestamp NULL AFTER `last_login`,
CHANGE `created_at` `created_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP AFTER `deleted_at`,
CHANGE `modified` `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

ALTER TABLE `bank_details`
CHANGE `updated_at` `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created_at`,
ADD `created` datetime NULL,
ADD `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

ALTER TABLE `shop_details`
CHANGE `updated_at` `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created_at`,
ADD `created` datetime NULL,
ADD `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

--- 3-08-2022

INSERT INTO `email_templates` (`id`, `title`, `slug`, `type`, `subject`, `description`, `short_codes`, `created`, `modified`) VALUES
(11,  'Verify Email', 'forgot-password',  'client',     'Verify Email', '<p>Dear {name}<br />\r\n<br />\r\nYour account one time password for email verify is <strong>{one_time_password}</strong>\r\n<br />\r\nThanks</p>','{first_name},{one_time_password}','2021-03-01 12:18:09', '2021-08-24 18:09:56');

UPDATE `email_templates` SET `short_codes` = '{name},{one_time_password}' WHERE `id` = '11';

INSERT INTO `email_templates` (`id`, `title`, `slug`, `type`, `subject`, `description`,`short_codes`,`created`, `modified`) VALUES
(12,  'Verify Email', 'resend-otp', 'client', 'Verify Email', '<p>Dear {name}<br />\r\n<br />\r\nYour account one time password for email verify is <strong>{one_time_password}</strong>\r\n<br />\r\nThanks</p>','{name},{one_time_password}','2021-03-01 12:18:09', '2021-08-24 18:09:56');

ALTER TABLE `countries`
CHANGE `sortname` `sortname` varchar(3) COLLATE 'utf8_general_ci' NULL AFTER `id`,
CHANGE `name` `name` varchar(150) COLLATE 'utf8_general_ci' NULL AFTER `sortname`,
CHANGE `phonecode` `phonecode` int(11) NULL AFTER `name`,
ADD `status` tinyint(4) NULL DEFAULT '1',
ADD `created` datetime NULL AFTER `status`,
ADD `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

ALTER TABLE `states`
ADD `status` tinyint(4) NULL DEFAULT '1' AFTER `country_id`,
ADD `created` datetime NULL,
ADD `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

ALTER TABLE `districts`
ADD `status` tinyint(4) NULL DEFAULT '1' AFTER `country_id`,
ADD `created` datetime NULL,
ADD `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

ALTER TABLE `cities`
ADD `status` tinyint(4) NULL DEFAULT '1' AFTER `country_id`,
ADD `created` datetime NULL,
ADD `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

ALTER TABLE `category`
CHANGE `updated_at` `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created_at`,
ADD `created` datetime NULL,
ADD `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

INSERT INTO `settings` (`id`, `name`, `value`) VALUES
(27,  'session_expires_in_minutes', '1440');


-- 03/08 
ALTER TABLE `admins`
ADD `status` tinyint(4) NULL DEFAULT '1' AFTER `decoded_password`,
CHANGE `created_at` `created_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `reset_password`;

ALTER TABLE `admins`
CHANGE `created_at` `created_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `reset_password`,
ADD `deleted_at` datetime NULL AFTER `created_at`;

ALTER TABLE `admins`
ADD `session_id` varchar(255) COLLATE 'latin1_swedish_ci' NULL AFTER `rememberToken`,
CHANGE `created_at` `created_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `reset_password`;