ALTER TABLE `smartrisk_dev`.`user_subscription_ratingchange` 
ADD COLUMN `sourcing_country_id` INT NOT NULL COMMENT '' AFTER `client_category_id`;

CREATE TABLE `client_credentials` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` int(10) unsigned NOT NULL,
  `client_name` varchar(255) NOT NULL,
  `username` varchar(1000) NOT NULL,
  `password` varchar(255) DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_by` int(11) DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `temp_client_credentials` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` int(10) unsigned NOT NULL,
  `client_name` varchar(255) NOT NULL,
  `username` varchar(1000) NOT NULL,
  `password` varchar(255) DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_by` int(11) DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `temp_client_credentials` 
ADD COLUMN `provider` varchar(100) DEFAULT NULL COMMENT '' AFTER `password`;

ALTER TABLE `client_credentials` 
ADD COLUMN `provider` varchar(100) DEFAULT NULL COMMENT '' AFTER `password`;


CREATE TABLE `client_supplier_ecovadis_data` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` int(10) unsigned NOT NULL,
  `client_name` varchar(255) NOT NULL,
  `supplier_name` varchar(1000) NOT NULL,
  `integration_id` varchar(255) DEFAULT NULL,

  `global_score` decimal(6,2) DEFAULT NULL,
  `fbp_score` decimal(6,2) DEFAULT NULL,

  `env_score` decimal(6,2) DEFAULT NULL,
  `lab_score` decimal(6,2) DEFAULT NULL,
  `sup_score` decimal(6,2) DEFAULT NULL,

  `published_date` date DEFAULT NULL,
  `valid_until` date DEFAULT NULL,
  `specific_comment` text DEFAULT NULL,
  `current_stage` varchar(100) DEFAULT NULL,

  `progress_status` varchar(100) DEFAULT NULL,
  `request_outcome` varchar(255) DEFAULT NULL,
  `sharing_status` varchar(100) DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_by` int(11) DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `temp_client_supplier_ecovadis_data` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` int(10) unsigned NOT NULL,
  `client_name` varchar(255) NOT NULL,
  `supplier_name` varchar(1000) NOT NULL,
  `integration_id` varchar(255) DEFAULT NULL,

  `global_score` decimal(6,2) DEFAULT NULL,
  `fbp_score` decimal(6,2) DEFAULT NULL,
  `env_score` decimal(6,2) DEFAULT NULL,
  `lab_score` decimal(6,2) DEFAULT NULL,
  `sup_score` decimal(6,2) DEFAULT NULL,

  `published_date` date DEFAULT NULL,
  `valid_until` date DEFAULT NULL,
  `specific_comment` text DEFAULT NULL,
  `current_stage` varchar(100) NOT NULL,

  `progress_status` varchar(100) DEFAULT NULL,
  `request_outcome` varchar(255) DEFAULT NULL,
  `sharing_status` varchar(100) DEFAULT NULL,

  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_by` int(11) DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


CREATE TABLE `api_provider_access_tokens` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` int(10) unsigned NOT NULL,
  `client_name` varchar(255) DEFAULT NULL,
  `username` varchar(1000) NOT NULL,
  `provider` varchar(255) NOT NULL,
  `access_token` varchar(500) NOT NULL,
  `expires_in` int(10) DEFAULT NULL,
  `issued_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `expires_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


CREATE TABLE `ecovadis_request_log` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` int(10) unsigned NOT NULL,
  `user_id` int(10) unsigned NOT NULL,
  `supplier_name` varchar(25) NOT NULL,
  `country` varchar(100) NOT NULL,
  `client_supplier_id` int(10) unsigned NOT NULL,
  `client_category_id` int(10) unsigned NOT NULL,
  `country_id` int(10) unsigned NOT NULL,
  `EV_Integration_ID` varchar(100) DEFAULT NULL,
  `supplier_contact_first_name` varchar(50) DEFAULT NULL,
  `supplier_contact_last_name` varchar(50) DEFAULT NULL,
  `supplier_contact_email` varchar(100) DEFAULT NULL,
  `supplier_contact_phone` varchar(20) DEFAULT NULL,
  `buyer_contact_first_name` varchar(50) DEFAULT NULL,
  `buyer_contact_last_name` varchar(50) DEFAULT NULL,
  `buyer_contact_email` varchar(100) DEFAULT NULL,
  `ecovadis_response` varchar(255) DEFAULT NULL,
  `campaign_type` varchar(100) DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` int(11) NOT NULL DEFAULT '0',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_by` int(11) DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

  CREATE TABLE `client_dashboards` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `client_id` int(10) unsigned NOT NULL,
    `strategic_dashboard` smallint(2) NOT NULL DEFAULT 1,
    `managed_dashboard` smallint(2) NOT NULL DEFAULT 1,
    `risk_hotspot` tinyint(1) DEFAULT NULL,
    `risk_aggregates` tinyint(1) DEFAULT NULL,
    `home_page` enum('1','2') NOT NULL DEFAULT 1,
    `is_active` tinyint(1) NOT NULL DEFAULT 1,
    `created_by` int(11) DEFAULT NULL,
    `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `updated_by` int(11) DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;


  landing page 1
  landing page 3
    
  home_page 1 or 2 

  ALTER TABLE `smartrisk_dev`.`client_dashboard` 
ADD COLUMN `landing_page` INT NULL DEFAULT 1 COMMENT '' AFTER `is_homepage`;


ALTER TABLE `smartrisk_dev`.`mst_user` 
ADD COLUMN `landing_page` INT NULL DEFAULT NULL COMMENT '' AFTER `is_homepage`;


ALTER TABLE `mst_user` 
ADD COLUMN `is_api_user` tinyint NULL DEFAULT NULL COMMENT '' AFTER `landing_page`;

CREATE TABLE `api_utility_log` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `client_id` int(10) unsigned NOT NULL,
  `user_id` int(10) unsigned NOT NULL,
  `api_method` varchar(100) NOT NULL,
  `called_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `api_call_configuration` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `max_api_call_limit` int(10) unsigned NOT NULL,
  `max_per_method_call_limit` int(10) unsigned NOT NULL,
  `max_supplier_code_limit` int(10) unsigned NOT NULL,
  `max_data_limit` int(10) unsigned NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


INSERT INTO `api_call_configuration` (`max_api_call_limit`, `max_per_method_call_limit`, `max_supplier_code_limit`, `max_data_limit`, `is_active`) VALUES ('100', '100', '500', '500', '1');







