CREATE TABLE `tblcpclub_listing_tenants_claim_otps`
( `tenant_id` BIGINT UNSIGNED NOT NULL , `cpclub_business_listing_id` BIGINT UNSIGNED NOT NULL , `token` VARCHAR
(255) NOT NULL , `otp` VARCHAR
(255) NOT NULL , `addedon` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_unicode_ci;

CREATE TABLE `tbltenant_business_listings_claimed`
( `id` BIGINT NOT NULL AUTO_INCREMENT , `tenant_id` BIGINT UNSIGNED NOT NULL , `cpclub_business_listing_id` BIGINT UNSIGNED NOT NULL , `type` ENUM
('claimed','added') NOT NULL , `addedon` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , PRIMARY KEY
(`id`)) ENGINE = InnoDB;


CREATE TABLE `tbloffline_cpclub_listing_claim_requests`
( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT , `tenant_id` BIGINT UNSIGNED NOT NULL , `cpclub_listings_id` BIGINT UNSIGNED NOT NULL , `requeston` DATETIME NOT NULL , `listing_type_while_claiming` ENUM
('unclaimed_listing','claimed_listing') NOT NULL , `addedon` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `request_status_id` INT NOT NULL , PRIMARY KEY
(`id`)) ENGINE = InnoDB;

CREATE TABLE `tbloffline_claim_request_status`
( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT , `name` VARCHAR
(255) NOT NULL , `addedon` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , PRIMARY KEY
(`id`)) ENGINE = InnoDB;

ALTER TABLE `tbloffline_claim_request_status`
ADD `codename` VARCHAR
(255) NOT NULL AFTER `id`,
ADD UNIQUE
(`codename`);


INSERT INTO `tbloffline_claim_request_status` (`id`,
`codename`,
`name`, `addedon`) VALUES
(NULL, 'pending', 'Pending', CURRENT_TIMESTAMP);

CREATE TABLE `tbloffline_cpclub_listing_claim_requests_history` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT , `action` VARCHAR(255) NOT NULL , `offline_cpclub_listing_claim_requests_id` BIGINT UNSIGNED NOT NULL , `tenant_id` BIGINT UNSIGNED NOT NULL , `cpclub_listings_id` BIGINT UNSIGNED NOT NULL , `requeston` DATETIME NOT NULL , `addedon` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `request_status_id` INT NOT NULL , `addedby` BIGINT UNSIGNED NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;
