-- jewel 76528  ANA Business solution_Table Def_20190909.xlsx

ALTER TABLE `person_contacts` 
CHANGE COLUMN `contact_id` `contact_id` VARCHAR(36) NOT NULL ,
CHANGE COLUMN `person_id` `person_id` VARCHAR(36) NOT NULL ,
CHANGE COLUMN `date_modified` `date_modified` DATETIME NOT NULL ,
CHANGE COLUMN `deleted` `deleted` TINYINT(3) NOT NULL DEFAULT '0' ,
CHANGE COLUMN `person_contact_status` `person_contact_status` VARCHAR(36) NOT NULL DEFAULT '0' ;

ALTER TABLE `smsevent` DROP COLUMN `opportunityNo`;
ALTER TABLE `accounts` DROP COLUMN `ana_flg`;


ALTER TABLE `smsevent` 
DROP COLUMN `field69`,
DROP COLUMN `field68`,
DROP COLUMN `field67`,
DROP COLUMN `salesstaff`,
DROP COLUMN `account_id`;

ALTER TABLE `contacts` DROP COLUMN `gokakusaki`;

-- Rio : 77645 ( add manual_transaction )
CREATE TABLE IF NOT EXISTS `manual_transaction` (
  `id` char(36) NOT NULL DEFAULT '',
  `salesno` varchar(36) DEFAULT NULL,
  `contact_name` varchar(36) DEFAULT NULL,
  `t_date` datetime DEFAULT NULL,
  `actual_in_amount` double DEFAULT NULL,
  `payment_type` varchar(36) DEFAULT NULL,
  `status` int DEFAULT NULL,
  `date_entered` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `date_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `modified_user_id` varchar(36) DEFAULT NULL,
  `created_by` varchar(36) DEFAULT NULL,
  `school_id` char(36) DEFAULT NULL ,
  `area_id` char(36) DEFAULT NULL,
  `nyuukinsaki_koza` int DEFAULT NULL,
  `bank_name` varchar(36) DEFAULT NULL,
  `bank_branch_name` varchar(36) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


ALTER TABLE `poll` DROP COLUMN `target_language`;
ALTER TABLE `poll` DROP COLUMN `school_id`;
ALTER TABLE `poll` DROP COLUMN `poll_category`;

ALTER TABLE `poll_vote` DROP COLUMN `answeres_excel`;
ALTER TABLE `poll_vote` DROP COLUMN `answeres`;

-- Jewel 77769
ALTER TABLE `manual_transaction` CHANGE COLUMN `salesno` `salesno` VARCHAR(100) NULL DEFAULT NULL ;

-- Jewel 78531
ALTER TABLE `sms_event_instance` DROP COLUMN `date_entered`;
ALTER TABLE `sms_event_instance` DROP COLUMN `created_by`;

-- Jed 79295 change primary key so that spec can save data on this table well
ALTER TABLE exam_grades 
DROP PRIMARY KEY , 
ADD PRIMARY KEY (id)

-- Jewel 79464
ALTER TABLE `exam_grades` CHANGE COLUMN `score` `score` VARCHAR(300) NULL DEFAULT NULL ;
 -- jewel 79741
ALTER TABLE `tracker` CHANGE COLUMN `item_summary` `item_summary` TEXT NULL DEFAULT NULL ;
-- jewel 81962
ALTER TABLE `manual_transaction` CHANGE COLUMN `contact_name` `contact_name` VARCHAR(48) NULL DEFAULT NULL ;