File: /www/exchange2/sql/archive/2015-12-16-271.sql
UPDATE statements SET currency=1 WHERE currency="EUR";
UPDATE statements SET currency=2 WHERE currency="GBP";
UPDATE statements SET currency=3 WHERE currency="USD";
UPDATE statements SET currency=3 WHERE currency=223;
UPDATE statements SET currency=2 WHERE currency=222;
UPDATE statements SET currency=1 WHERE currency=104;
UPDATE statements SET currency=1 WHERE currency=241;
ALTER TABLE `statements` CHANGE COLUMN `currency` `currency` TINYINT(50) UNSIGNED NOT NULL DEFAULT '0' AFTER `investor_id`;
ALTER TABLE `statements` CHANGE COLUMN `reserve_on` `reserve_on` TINYINT(4) UNSIGNED NOT NULL COMMENT '0-not reserved,1-reserved' AFTER `cumulative_balance`, CHANGE COLUMN `status` `status` TINYINT(2) UNSIGNED NOT NULL COMMENT '0-EFT, 1-CSH, 2-ETRPURCHASED, 3-ETRBLOCKPURCHASED,4-ETRBUYOUT,5-ETRSETTLED,6-ETROFFSET,7-ETRREPURCHASE' AFTER `reserve_on`;
ALTER TABLE `statements` CHANGE COLUMN `manual_transaction_id` `manual_transaction_id` MEDIUMINT(20) UNSIGNED NOT NULL AFTER `reference_id`;
ALTER TABLE `statements` CHANGE COLUMN `bulk_id` `bulk_id` SMALLINT(40) UNSIGNED NOT NULL AFTER `manual_transaction_id`;
ALTER TABLE `statements` CHANGE COLUMN `originator_id` `originator_id` SMALLINT(40) UNSIGNED NOT NULL AFTER `bulk_id`;
ALTER TABLE `site_settings` ADD COLUMN `investment_leverage` DECIMAL(5,4) UNSIGNED NOT NULL DEFAULT '0.9863';
ALTER TABLE `temp_retailer` DROP COLUMN `amount_received`;
ALTER TABLE `temp_retailer` DROP COLUMN `to_receive`;
ALTER TABLE `temp_retailer` DROP COLUMN `current_amount`;
ALTER TABLE `temp_retailer` DROP COLUMN `amount_invested`;
ALTER TABLE `temp_retailer` DROP COLUMN `period_month`, DROP COLUMN `period_year`;
ALTER TABLE `temp_retailer` DROP COLUMN `amount`;
ALTER TABLE `temp_retailer` CHANGE COLUMN `quote_rate` `quote_rate` DECIMAL(5,3) NOT NULL AFTER `modified_at`;
ALTER TABLE `invoice_closed` CHANGE COLUMN `won_by` `won_by` SMALLINT(20) UNSIGNED NOT NULL AFTER `invoice_id`;
ALTER TABLE `invoice_closed` CHANGE COLUMN `invoice_id` `invoice_id` MEDIUMINT(20) UNSIGNED NOT NULL AFTER `bulk_closed_id`;
ALTER TABLE `invoice_bulk_closed` CHANGE COLUMN `bulk_id` `bulk_id` MEDIUMINT(40) UNSIGNED NOT NULL AUTO_INCREMENT FIRST, CHANGE COLUMN `investor_id` `investor_id` SMALLINT(40) UNSIGNED NOT NULL AFTER `bulk_ref_id`;
ALTER TABLE `temp_registration` CHANGE COLUMN `user_id` `user_id` SMALLINT(40) UNSIGNED NULL DEFAULT NULL AFTER `desc`;
ALTER TABLE `invoice_closed` CHANGE COLUMN `bulk_closed_id` `bulk_closed_id` MEDIUMINT(40) UNSIGNED NOT NULL AFTER `closed_ref_id`;
ALTER TABLE `invoice_closed` CHANGE COLUMN `accept_status` `accept_status` TINYINT(2) UNSIGNED NOT NULL DEFAULT '0' AFTER `close_time`;
ALTER TABLE `invoice_bidding` CHANGE COLUMN `invoice_bidding_id` `invoice_bidding_id` MEDIUMINT(40) UNSIGNED NOT NULL AUTO_INCREMENT FIRST, CHANGE COLUMN `user_id` `user_id` SMALLINT(20) UNSIGNED NOT NULL AFTER `invoice_bidding_id`, CHANGE COLUMN `invoice_id` `invoice_id` MEDIUMINT(20) UNSIGNED NOT NULL AFTER `user_id`;
ALTER TABLE `invoice_closed` CHANGE COLUMN `invoice_bidding_id` `invoice_bidding_id` MEDIUMINT(40) UNSIGNED NOT NULL AFTER `value_return`;
ALTER TABLE `investor_relation` CHANGE COLUMN `relation_id` `relation_id` SMALLINT(40) UNSIGNED NOT NULL AUTO_INCREMENT FIRST, CHANGE COLUMN `investor_id` `investor_id` SMALLINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `relation_id`, CHANGE COLUMN `intermediary_id` `intermediary_id` SMALLINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `investor_id`;
ALTER TABLE `state_master` CHANGE COLUMN `state_id` `state_id` SMALLINT(100) UNSIGNED NOT NULL FIRST, CHANGE COLUMN `country_id` `country_id` TINYINT(25) UNSIGNED NOT NULL AFTER `state_id`, CHANGE COLUMN `modified_by` `modified_by` TINYINT(40) UNSIGNED NULL DEFAULT NULL COMMENT 'user_id from user_registration Table' AFTER `state_name`;
CREATE TABLE `transaction_types` (
`transaction_id` TINYINT(3) UNSIGNED NULL DEFAULT NULL,
`type_id` TINYINT(3) UNSIGNED NULL DEFAULT NULL COMMENT '1 - investor transactions, 2 - manual transactions',
`transaction_name` VARCHAR(100) NULL DEFAULT NULL,
`bogui_active` TINYINT(3) UNSIGNED NULL DEFAULT '1',
INDEX `Index 1` (`transaction_id`, `type_id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT;
INSERT INTO `transaction_types` (`transaction_id`, `type_id`, `transaction_name`, `bogui_active`) VALUES (1, 1, 'RPA Receipt', 1);
INSERT INTO `transaction_types` (`transaction_id`, `type_id`, `transaction_name`, `bogui_active`) VALUES (2, 1, 'Coupon', 1);
INSERT INTO `transaction_types` (`transaction_id`, `type_id`, `transaction_name`, `bogui_active`) VALUES (3, 1, 'Redemption', 1);
INSERT INTO `transaction_types` (`transaction_id`, `type_id`, `transaction_name`, `bogui_active`) VALUES (4, 1, 'Redeemed', 1);
INSERT INTO `transaction_types` (`transaction_id`, `type_id`, `transaction_name`, `bogui_active`) VALUES (5, 1, 'Compound', 1);
INSERT INTO `transaction_types` (`transaction_id`, `type_id`, `transaction_name`, `bogui_active`) VALUES (6, 1, 'Buy Rate Yield', 0);
INSERT INTO `transaction_types` (`transaction_id`, `type_id`, `transaction_name`, `bogui_active`) VALUES (7, 1, 'Reinvestment', 1);
INSERT INTO `transaction_types` (`transaction_id`, `type_id`, `transaction_name`, `bogui_active`) VALUES (8, 1, 'Addition', 1);
INSERT INTO `transaction_types` (`transaction_id`, `type_id`, `transaction_name`, `bogui_active`) VALUES (9, 1, 'Continue', 1);
CREATE TABLE `investor_investments` (
`investment_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
`investment_date` DATE NULL DEFAULT NULL,
`investment_group` SMALLINT(3) UNSIGNED NULL DEFAULT '0',
`investor_id` MEDIUMINT(8) UNSIGNED NULL DEFAULT '0',
`currency_id` TINYINT(3) UNSIGNED NULL DEFAULT '0',
`investment_type` TINYINT(3) UNSIGNED NULL DEFAULT '0',
`amount` DECIMAL(10,2) UNSIGNED NULL DEFAULT '0.00',
`buy_rate` DOUBLE(4,3) UNSIGNED NULL DEFAULT '0.000',
`commission` DOUBLE(4,3) UNSIGNED NULL DEFAULT '0.000',
`months` TINYINT(3) UNSIGNED NULL DEFAULT '0',
`early_exit` DATE NULL DEFAULT NULL,
`change_id` SMALLINT(5) UNSIGNED NULL DEFAULT '0',
`comment` TINYTEXT NULL,
`status` TINYINT(3) UNSIGNED NULL DEFAULT '0',
`created_by` TINYINT(3) UNSIGNED NULL DEFAULT '0',
`created_at` DATETIME NULL DEFAULT NULL,
`modified_by` TINYINT(3) UNSIGNED NULL DEFAULT '0',
`modified_at` DATETIME NULL DEFAULT NULL,
`authorised_by` TINYINT(3) UNSIGNED NULL DEFAULT '0',
`authorised_at` DATETIME NULL DEFAULT NULL,
PRIMARY KEY (`investment_id`),
INDEX `Index 2` (`investor_id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
AUTO_INCREMENT=563;