

### DO NOT ADD ANYTHING TO THIS FILE #################################################
#
# Use dev_updates.sql instead.
# 
###############################################################################



### END OF TESTING UPDATES########################################################
#
#These are changes that were made for some local dev efforts. 
# 
###############################################################################

#These are things that were local only changes. They will likely never be implemented. 
# gift_design slugs
ALTER TABLE `gift_design` ADD `slug` TINYINT( 1 ) NOT NULL DEFAULT '0';
ALTER TABLE `org_partner` ADD `slug_opt_in` TINYINT( 1 ) NOT NULL DEFAULT '0',
ADD `partner_inactive` TINYINT( 1 ) NOT NULL DEFAULT '0';

# template pages by brand
ALTER TABLE `page` ADD `brand_org` INT( 11 ) NULL AFTER `template` ;
ALTER TABLE `page` ADD INDEX ( `brand_org` ) ;
ALTER TABLE `page` ADD FOREIGN KEY ( `brand_org` ) REFERENCES `sevence`.`org` (`org`);
UPDATE page SET brand_org = 13 WHERE brand_org IS NULL AND template IS NOT NULL AND org IS NULL;
ALTER TABLE `page_nav` ADD `brand_org` INT( 11 ) NULL AFTER `template` ;
ALTER TABLE `page_nav` ADD INDEX ( `brand_org` ) ;
ALTER TABLE `page_nav` ADD FOREIGN KEY ( `brand_org` ) REFERENCES `sevence`.`org` (`org`);
UPDATE page_nav SET brand_org = 13 WHERE brand_org IS NULL AND template IS NOT NULL AND org IS NULL;

# email status
ALTER TABLE client_address ADD COLUMN email_status tinyint not null default 0 AFTER email;

ALTER TABLE gift_api ADD COLUMN type tinyint NOT NULL DEFAULT 0;

# billing options (NOT on testing)...

RENAME TABLE `sevence`.`billing_signup_tran` TO `sevence`.`billing_option_tran`;
ALTER TABLE `billing_option_tran` CHANGE `billing_signup_tran` `billing_option_tran` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `billing_option_tran`
	ADD `org` INT NULL AFTER `billing_option_tran` ,
	ADD `client_help` INT NULL AFTER `org` ,
	ADD `cc_info` VARCHAR( 100 ) NULL AFTER `client_help` ;
UPDATE billing_option_tran SET cc_info = CONCAT_WS( '|', COALESCE(cc_num, ''), COALESCE(cc_type, ''),
	COALESCE(cc_exp_mo, ''), COALESCE(cc_exp_year, ''), COALESCE(cc_name, ''));
ALTER TABLE `billing_option_tran`
  DROP `cc_num`,
  DROP `cc_type`,
  DROP `cc_exp_mo`,
  DROP `cc_exp_year`,
  DROP `cc_name`;

drop table billing_option_org;
drop table billing_option;

CREATE TABLE `billing_option` (
  `billing_option` int(11) NOT NULL auto_increment,
  `brand_org` int(11) default NULL,
  `service_option` int(11) default NULL,
  `option_desc` varchar(80) NOT NULL default '',
  `headline` text NOT NULL,
  `option_text` text,
  `price` decimal(12,2) NOT NULL default '0.00',
  `option_available` tinyint(4) NOT NULL default '1',
  PRIMARY KEY  (`billing_option`),
  KEY `brand_org` (`brand_org`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

ALTER TABLE `billing_option`
  ADD CONSTRAINT `billing_option_ibfk_1` FOREIGN KEY (`brand_org`) REFERENCES `brand` (`org`);

CREATE TABLE `billing_option_org` (
  `billing_option_org` int(11) NOT NULL auto_increment,
  `billing_option` int(11) NOT NULL default '0',
  `org` int(11) NOT NULL default '0',
  `billing_item` int(11) default NULL,
  `entered_date` datetime default NULL,
  PRIMARY KEY  (`billing_option_org`),
  KEY `org` (`org`),
  KEY `billing_option` (`billing_option`),
  KEY `billing_item` (`billing_item`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

ALTER TABLE `billing_option_org`
  ADD CONSTRAINT `billing_option_org_ibfk_3` FOREIGN KEY (`billing_item`) REFERENCES `billing_item` (`billing_item`),
  ADD CONSTRAINT `billing_option_org_ibfk_1` FOREIGN KEY (`org`) REFERENCES `org` (`org`),
  ADD CONSTRAINT `billing_option_org_ibfk_2` FOREIGN KEY (`billing_option`) REFERENCES `billing_option` (`billing_option`);

INSERT INTO `sevence`.`billing_option` (`billing_option`, `brand_org`, `description`, `headline`,`option_text`, `price`, `option_available`)
	VALUES (10, 409, 'BoomTime setup fee', 'BoomTime setup fee', 'BoomTime setup fee', 0.00, -1);

# move credit forwards from billing_item_type 0 to -2 (NOT on testing)...

UPDATE billing_item_type SET billing_item_type = -2 WHERE billing_item_type = 0 AND substr(billing_item_desc, 1, 15) = 'Credit forward:';

# create meta_head column and set it to equal meta_gmap full value

ALTER TABLE website ADD COLUMN meta_head TEXT;
ALTER TABLE page ADD COLUMN meta_head TEXT;

UPDATE website SET meta_head = CONCAT('<meta name="verify-v1" content="', meta_gmap, '" />\n
<meta name="google-site-verification" content="', meta_gmap, '" />')
WHERE meta_gmap != '';

