#Update for 01.16.13
INSERT INTO email_marketing (default_email,type,id,org,active,name,subject,headline,narrative,body,send_on,email_cycle,queued_on,hide,show_event,show_article,email_design,client_or_org,client_type,marketing_list,marketing_list_opt,org_type,org_restrict,editor,photo,photo_filename,offer,event,campaign_type,push_type,edit_date,edit_prof,permalink,show_reward,email_trigger)
	VALUES (null,2,'generic',3,1,'brand generic','Hello from {brand_short_name}',NULL,NULL,NULL,NULL,0,NULL,0,0,0,5,0,0,0,0,'ALL','NONE',0,0,'',0,0,0,0,'2012-11-30 13:00:00',2130,'brand-generic',0,NULL);
INSERT INTO email_marketing (default_email,type,id,org,active,name,subject,headline,narrative,body,send_on,email_cycle,queued_on,hide,show_event,show_article,email_design,client_or_org,client_type,marketing_list,marketing_list_opt,org_type,org_restrict,editor,photo,photo_filename,offer,event,campaign_type,push_type,edit_date,edit_prof,permalink,show_reward,email_trigger)
	VALUES (null,2,'generic',967,1,'brand generic','Hello from {brand_short_name}',NULL,NULL,NULL,NULL,0,NULL,0,0,0,5,0,0,0,0,'ALL','NONE',0,0,'',0,0,0,0,'2012-11-30 13:00:00',2130,'brand-generic',0,NULL);
INSERT INTO email_marketing (default_email,type,id,org,active,name,subject,headline,narrative,body,send_on,email_cycle,queued_on,hide,show_event,show_article,email_design,client_or_org,client_type,marketing_list,marketing_list_opt,org_type,org_restrict,editor,photo,photo_filename,offer,event,campaign_type,push_type,edit_date,edit_prof,permalink,show_reward,email_trigger)
	VALUES (null,2,'generic',2850,1,'brand generic','Hello from {brand_short_name}',NULL,NULL,NULL,NULL,0,NULL,0,0,0,5,0,0,0,0,'ALL','NONE',0,0,'',0,0,0,0,'2012-11-30 13:00:00',2130,'brand-generic',0,NULL);
INSERT INTO email_marketing (default_email,type,id,org,active,name,subject,headline,narrative,body,send_on,email_cycle,queued_on,hide,show_event,show_article,email_design,client_or_org,client_type,marketing_list,marketing_list_opt,org_type,org_restrict,editor,photo,photo_filename,offer,event,campaign_type,push_type,edit_date,edit_prof,permalink,show_reward,email_trigger)
	VALUES (null,2,'generic',7703,1,'brand generic','Hello from {brand_short_name}',NULL,NULL,NULL,NULL,0,NULL,0,0,0,5,0,0,0,0,'ALL','NONE',0,0,'',0,0,0,0,'2012-11-30 13:00:00',2130,'brand-generic',0,NULL);
INSERT INTO email_marketing (default_email,type,id,org,active,name,subject,headline,narrative,body,send_on,email_cycle,queued_on,hide,show_event,show_article,email_design,client_or_org,client_type,marketing_list,marketing_list_opt,org_type,org_restrict,editor,photo,photo_filename,offer,event,campaign_type,push_type,edit_date,edit_prof,permalink,show_reward,email_trigger)
	VALUES (null,2,'generic',8090,1,'brand generic','Hello from {brand_short_name}',NULL,NULL,NULL,NULL,0,NULL,0,0,0,5,0,0,0,0,'ALL','NONE',0,0,'',0,0,0,0,'2012-11-30 13:00:00',2130,'brand-generic',0,NULL);
INSERT INTO email_marketing (default_email,type,id,org,active,name,subject,headline,narrative,body,send_on,email_cycle,queued_on,hide,show_event,show_article,email_design,client_or_org,client_type,marketing_list,marketing_list_opt,org_type,org_restrict,editor,photo,photo_filename,offer,event,campaign_type,push_type,edit_date,edit_prof,permalink,show_reward,email_trigger)
	VALUES (null,2,'generic',8392,1,'brand generic','Hello from {brand_short_name}',NULL,NULL,NULL,NULL,0,NULL,0,0,0,5,0,0,0,0,'ALL','NONE',0,0,'',0,0,0,0,'2012-11-30 13:00:00',2130,'brand-generic',0,NULL);
UPDATE email_marketing set push_type=1 where id='generic';

ALTER TABLE brand ADD support_email VARCHAR( 40 ) NULL DEFAULT NULL AFTER accounting_email;

UPDATE brand SET support_email = 'support@boomtime.com' where brand=1;
UPDATE brand SET support_email = 'support@spaboom.com' where brand=2;
UPDATE brand SET support_email = 'support@coverboom.com' where brand=3;
UPDATE brand SET support_email = 'support@spaboom.com' where brand=4;
UPDATE brand SET support_email = 'support@boomtime.com' where brand=5;
UPDATE brand SET support_email = 'support@printingforless.com' where brand=6;
UPDATE brand SET support_email = 'support@spaboom.com' where brand=7;
UPDATE brand SET support_email = 'support@rsvpmarketingsuite.com' where brand=8;
UPDATE brand SET support_email = 'support@victoryexpand.com' where brand=9;
UPDATE brand SET support_email = 'support@engagegolf.com' where brand=10
#JBB 11.30.2012 Mantis0000784: Email org when facebook integration is broken

CREATE TABLE `data_org_week` (
  `org` int(11) NOT NULL,
  `year` int(11) NOT NULL,
  `week` int(11) NOT NULL,
  `sales` double DEFAULT NULL,
  `signup_email` int(11) DEFAULT NULL,
  `review` int(11) DEFAULT NULL,
  `article_comment` int(11) DEFAULT NULL,
  `birthday` int(11) DEFAULT NULL,
  `anniversary` int(11) DEFAULT NULL,
  `dailydeal` int(11) DEFAULT NULL,
  `fb_fan` int(11) DEFAULT NULL,
  `pickup_dailydeal` int(11) DEFAULT NULL,
  `pickup_ondemand` int(11) DEFAULT NULL,
  `pickup_signup` int(11) DEFAULT NULL,
  `pickup_sweepstakes` int(11) DEFAULT NULL,
  `pickup_birthday` int(11) DEFAULT NULL,
  `pickup_anniversary` int(11) DEFAULT NULL,
  `request` int(11) DEFAULT NULL,
  `book` int(11) DEFAULT NULL,
  PRIMARY KEY (`org`,`year`,`week`)
);
ALTER TABLE data_org_week ADD COLUMN yearweek char(6) NOT NULL AFTER org;
ALTER TABLE data_org_week DROP PRIMARY KEY;
ALTER TABLE data_org_week ADD PRIMARY KEY (org, yearweek);
ALTER TABLE data_org_week DROP COLUMN year, DROP COLUMN week;
INSERT INTO `org_parm` (`org_parm`, `org`, `type`, `parm`, `value`) VALUES
(72301, 13, 'Yelp', 'consumer_key', 'qxhfe7HN8RNBx_eWIsab-w'),
(72302, 13, 'Yelp', 'consumer_secret', 'olgWxJfMsJilBYZicjzKjUdwypA'),
(72303, 13, 'Yelp', 'token', 'UEh8RKVc9zrwMefrxlWzyaf4UNhAdtR-'),
(72304, 13, 'Yelp', 'token_secret', '9s9C4de3GNVm7LRNyQDPoe7aJPQ');

#11.19.12 DWS Mantis0000658: Org data

ALTER TABLE review ADD COLUMN rating_only tinyint NOT NULL DEFAULT 0 AFTER rating;
#01.08.13 DWS Mantis0000933 Additional Changes to Changes to Reviews

ALTER TABLE data_org_week ADD COLUMN rating int(11) AFTER review, ADD COLUMN rating_avg tinyint AFTER rating;
#01.09.13 DWS Mantis0000934: Additional Changes to Robometrics

ALTER TABLE data_org_week ADD COLUMN gc_count int(11) AFTER sales;
ALTER TABLE data_org_week MODIFY rating_avg decimal (2, 1);
ALTER TABLE data_org_week CHANGE sales sales double DEFAULT 0, CHANGE gc_count gc_count int(11) DEFAULT 0, CHANGE signup_email signup_email int(11) DEFAULT 0, CHANGE review review int(11) DEFAULT 0, ADD COLUMN review_ext int(11) DEFAULT 0 AFTER review, CHANGE rating rating int(11) DEFAULT 0, CHANGE rating_avg rating_avg decimal(2,1) DEFAULT 0, CHANGE article_comment article_comment int(11) DEFAULT 0, CHANGE birthday birthday int(11) DEFAULT 0, CHANGE anniversary anniversary int(11) DEFAULT 0, CHANGE dailydeal dailydeal int(11) DEFAULT 0, CHANGE fb_fan fb_fan int(11) DEFAULT 0, CHANGE pickup_dailydeal pickup_dailydeal int(11) DEFAULT 0, CHANGE pickup_ondemand pickup_ondemand int(11) DEFAULT 0, CHANGE pickup_signup pickup_signup int(11) DEFAULT 0, CHANGE pickup_sweepstakes pickup_sweepstakes int(11) DEFAULT 0, CHANGE pickup_birthday pickup_birthday int(11) DEFAULT 0, CHANGE pickup_anniversary pickup_anniversary int(11) DEFAULT 0, CHANGE request request int(11) DEFAULT 0, CHANGE book book int(11) DEFAULT 0;

CREATE TABLE org_auto_season (org_auto_season int(11) primary key auto_increment, org int(11) not null, type varchar(6) not null default "closed", starts_at date not null, ends_at date not null, index `org` (`org`), constraint `org_auto_season_org_fk` foreign key org (org) references org (org));
ALTER TABLE brand ADD COLUMN use_seasons tinyint(1) NOT NULL DEFAULT 0;
UPDATE brand SET use_seasons=1 where brand=10;
#Changes to the diagnostic for Engage
#End 01/16.13 update

#01/16/13 update Part II
ALTER TABLE org_auto_season MODIFY COLUMN `starts_at` int(11) NOT NULL DEFAULT 1;
ALTER TABLE org_auto_season MODIFY COLUMN `ends_at` int(11) NOT NULL DEFAULT 1;

ALTER TABLE `org_client`
  ADD `org_client_1` varchar(40) NULL DEFAULT NULL AFTER `org_client`,
  ADD `org_client_2` varchar(40) NULL DEFAULT NULL AFTER `org_client_1`;
#1.16.2013 JBB Mantis0000950: Changes to the import/update routine for Engage
#end 01/16/13 update part II

#02/18/13 update
  ADD `org_client_1` varchar(40) NULL DEFAULT NULL,
  ADD `org_client_2` varchar(40) NULL DEFAULT NULL AFTER `org_client_1`;
#1.16.2013 JBB Mantis0000950: Changes to the import/update routine for Engage
#END 01/16/13 update PART II

#02.18.13 update

ALTER TABLE client_address ADD COLUMN latitude DECIMAL(10,6), ADD COLUMN longitude DECIMAL(10,6);
#DWS 1.24.13 956 Create KML and Geo Sitemap file

ALTER TABLE org MODIFY COLUMN service_gc tinyint(4) NOT NULL DEFAULT 0;
#SRG 2.7.13 985 service_gc is not boolean

#END 02.18.13 update

#BEGIN 3/6/13 Update
CREATE TABLE `reward` (
  `org` int(11) NOT NULL,
  `program_name` varchar(100) DEFAULT NULL,
  `accum_points` text,
  `no_points` text,
  `auto_redeem` tinyint(4) NOT NULL DEFAULT '0',
  `redeem_level` int(11) DEFAULT '1000',
  `redeem_value` decimal(12,2) DEFAULT '100.00',
  `org_gift_design` int(11) DEFAULT NULL,
  `gift_message` text,
  KEY `org` (`org`),
  CONSTRAINT `reward_ibfk_1` FOREIGN KEY (`org`) REFERENCES `org` (`org`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
#DWS 2.16.13 509 Automatic redemption program
#END 3/6/13 update

#4/7/13 update
ALTER TABLE website ADD COLUMN event_news_limit int NOT NULL DEFAULT -1;
#DWS 04.03.2013 M678. Number of news events to display in sidebar
#END 4/7/13 update

#4/17/13 update
ALTER TABLE queue_social ADD COLUMN post_option tinyint(4) NOT NULL DEFAULT 0 AFTER type;
#DWS 04.10.12 M745 Photos and FB posts

INSERT INTO part (org, part_id, content) VALUES (3, 'email_narr_igc', "It's the perfect, thoughtful gift of relaxation -- an Instant Gift Certificate from {company}.\n\n{instant_gc_link(0, 'Purchase an Instant Gift Certificate')}\n{website_link('Visit our website')}");
INSERT INTO part (org, part_id, content) VALUES (2850, 'email_narr_igc', "It's the perfect, thoughtful gift for any occasion -- an Instant Gift Certificate from {company}.\n\n{instant_gc_link(0, 'Purchase an Instant Gift Certificate')}\n{website_link('Visit our website')}");
INSERT INTO part (org, part_id, content) VALUES (3, 'email_narrative', "See the latest of what we have to offer: {website_link('Visit our website')}");
#DWS 04.10.13 M0001048: Default language in a new email should be more customizable per brand/org type

UPDATE event SET id = 'facebook-fan' WHERE id is null AND name = "Find us on FaceBook";
UPDATE event SET id = 'twitter-follow' WHERE id is null AND name = "Follow us on Twitter";
#JBB 04.16.13 Data clean up on social media events in preparation for use of the new Social Media Icon tag
#END 4/17/13 Update

#BEGIN 4.28.2013 UPDATE
ALTER TABLE org_setting ADD COLUMN google_plusone_event tinyint NOT NULL DEFAULT 1, ADD COLUMN google_plusone_article tinyint NOT NULL DEFAULT 1;
#DWS 04.15.13 M0000920 Google + integration

ALTER TABLE data_org_week ADD COLUMN referred_signup int(11), ADD COLUMN referred_booking int(11), ADD COLUMN referred_gc int(11);
ALTER TABLE book ADD COLUMN reward_gift_amount int(11), ADD COLUMN reward_refer_gift_amount int(11);
#DWS 04.23.13 M0001072: Add referral data to Robometrics

INSERT INTO part (org, part_id, content) VALUES (3, 'share_sub', 'New website to check out...');
INSERT INTO part (org, part_id, content) VALUES (3, 'share_sub_auto', '{reward_redeem_value} off at {short_name} today!');
INSERT INTO part (org, part_id, content) VALUES (3, 'share_body', 'I found a new website, {company}, that I wanted to share with you. Check it out!');
INSERT INTO part (org, part_id, content) VALUES (3, 'share_body_auto', 'I want you to enjoy the same personalized service I get at {short_name}. Sign up for their newsletter and you\'ll get {reward_email_signup} points instantly! With just {reward_redeem_points} you\'ll get your first of many {reward_redeem_value} reward gift certificates. Start watching your reward points grow!');
#DWS 04.26.13 M0001086: changes to the Share tag

ALTER TABLE client ADD COLUMN stripe_customer VARCHAR( 40 ) NULL AFTER client_opt_in;
ALTER TABLE client ADD COLUMN save_cc tinyint(1) NULL AFTER stripe_customer;
#MGK 4.15.2013: stripeProcessing - Add a column to store customer object id's from stripe to charge CC's in the future and SAVE CC value

INSERT INTO proc_reason (processing, reason_code, `desc`) VALUES(1, 28, "Your card's security code is incorrect");
INSERT INTO proc_reason (processing, reason_code, `desc`) VALUES(1, 29, "An error occurred while processing your card");
#MGK 4.19.2013: stripeProcessing - Add data to the proc reason table for stripe reason codes.

INSERT INTO  task (brand_org, `type`, content, sort) VALUES(13, 1, "Finish setting up your credit card processing in <a id='a_cc' href='cc_processing.php' title='Credit Card Processing Setup'>CC Processing</a>.", 0.400000);
INSERT INTO  task (brand_org, `type`, content, sort) VALUES(409, 1, "Finish setting up your credit card processing in <a id='a_cc' href='cc_processing.php' title='Credit Card Processing Setup'>CC Processing</a>.", 0.400000);
INSERT INTO  task (brand_org, `type`, content, sort) VALUES(2646, 1, "Finish setting up your credit card processing in <a id='a_cc' href='cc_processing.php' title='Credit Card Processing Setup'>CC Processing</a>.", 0.400000);
INSERT INTO  task (brand_org, `type`, content, sort) VALUES(2963, 1, "Finish setting up your credit card processing in <a id='a_cc' href='cc_processing.php' title='Credit Card Processing Setup'>CC Processing</a>.", 0.400000);
INSERT INTO  task (brand_org, `type`, content, sort) VALUES(5673, 1, "Finish setting up your credit card processing in <a id='a_cc' href='cc_processing.php' title='Credit Card Processing Setup'>CC Processing</a>.", 0.400000);
INSERT INTO  task (brand_org, `type`, content, sort) VALUES(7400, 1, "Finish setting up your credit card processing in <a id='a_cc' href='cc_processing.php' title='Credit Card Processing Setup'>CC Processing</a>.", 0.400000);
INSERT INTO  task (brand_org, `type`, content, sort) VALUES(7464, 1, "Finish setting up your credit card processing in <a id='a_cc' href='cc_processing.php' title='Credit Card Processing Setup'>CC Processing</a>.", 0.400000);
INSERT INTO  task (brand_org, `type`, content, sort) VALUES(7772, 1, "Finish setting up your credit card processing in <a id='a_cc' href='cc_processing.php' title='Credit Card Processing Setup'>CC Processing</a>.", 0.400000);
INSERT INTO  task (brand_org, `type`, content, sort) VALUES(7836, 1, "Finish setting up your credit card processing in <a id='a_cc' href='cc_processing.php' title='Credit Card Processing Setup'>CC Processing</a>.", 0.400000);
INSERT INTO  task (brand_org, `type`, content, sort) VALUES(8324, 1, "Finish setting up your credit card processing in <a id='a_cc' href='cc_processing.php' title='Credit Card Processing Setup'>CC Processing</a>.", 0.400000);

#MGK 4.19.2013: stripeProcessing - Add tasks to the task table for when orgs signup.

UPDATE reward SET accum_points='You''ve earned {reward_points} reward points with {reward_program}! Earn more points when you purchase an {instant_gc_link} or {share_link} and watch your points grow. When you reach {reward_redeem_points} we''ll immediately send you a gift certificate for {reward_redeem_value}, so watch your email!' WHERE org IN (3, 2850, 8392);
UPDATE reward SET no_points='You''ve not yet earned any {reward_program} points, but it''s easy to do! Earn points when you purchase an {instant_gc_link} or {share_link} and watch your points grow. When you reach {reward_redeem_points} we''ll immediately send you a gift certificate for {reward_redeem_value}, so watch your email!' WHERE org IN (3, 2850, 8392);
UPDATE reward SET gift_message='You''ve earned a {reward_redeem_value} reward! We look forward to seeing you again at {short_name}.' WHERE org IN (3, 2850, 8392);
UPDATE reward SET redeem_level=500, redeem_value='25.00' WHERE org IN (3, 2850, 8392);
UPDATE part SET content='<h1>Share with a friend!</h1><p>Your friends deserve to know about your favorite spa, {short_name}. Share our website with them right now, and encourage them to sign up for our newsletter.' where part_id='share_h' and org=3
INSERT INTO part (org, part_id, content) VALUES (7415, 'share_h', '<h1>Share with a friend!</h1><p>Your friends deserve to know about your favorite salon, {short_name}. Share our website with them right now, and encourage them to sign up for our newsletter.');
INSERT INTO part (org, part_id, content) VALUES (7193, 'share_h', '<h1>Share with a friend!</h1><p>Your friends deserve to know about your favorite salon/spa, {short_name}. Share our website with them right now, and encourage them to sign up for our newsletter.');
INSERT INTO part (org, part_id, content) VALUES (7195, 'share_h', '<h1>Share with a friend!</h1><p>Your friends deserve to know about your favorite massage therapist, {short_name}. Share our website with them right now, and encourage them to sign up for our newsletter.');
INSERT INTO part (org, part_id, content) VALUES (8215, 'share_h', '<h1>Share with a friend!</h1><p>Your friends deserve to know about your favorite aesthetician, {short_name}. Share our website with them right now, and encourage them to sign up for our newsletter.');
UPDATE part SET content='We’ll give you {reward_share_signup} points for each friend that signs up! Even better, they earn {reward_email_signup} points just for signing up, and you both get points for their first purchase!' WHERE part_id='reward_share' AND org in (3, 2850);
INSERT into part (org, part_id, content) VALUES (8392, 'reward_share', 'We’ll give you {reward_share_signup} points for each friend that signs up! Even better, they earn {reward_email_signup} points just for signing up, and you both get points for their first purchase!') ;
#SLOW 4.28.2013 part and default settings for rewards, referral and share programs
#END 4.28.2013 UPDATE

#BEGIN 4.30.2013 UPDATE
CREATE TABLE `website_widget` (
  `org` int(11) NOT NULL,
  `items` int(11) DEFAULT NULL,
  `show_description` tinyint(4) DEFAULT NULL,
  `opt_headline` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`org`),
  CONSTRAINT `website_widget_ibfk_1` FOREIGN KEY (`org`) REFERENCES `org` (`org`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
#DWS 4.30.13 M0001075: Blog widget part II

ALTER TABLE data_org_week ADD COLUMN referred_signup int(11), ADD COLUMN referred_booking int(11), ADD COLUMN referred_gc int(11);
ALTER TABLE book ADD COLUMN reward_gift_amount int(11), ADD COLUMN reward_refer_gift_amount int(11);
#DWS 04.23.13 M0001072: Add referral data to Robometrics
#END 4.30.2013 UPDATE

#BEGIN 5.20.2013 UPDATE
ALTER TABLE website ADD COLUMN meta_verify_tag varchar(50), ADD COLUMN meta_verify_content varchar(100);
#DWS 4.20.13 M0000921 Pinterest authentication

ALTER TABLE gift_amount ADD COLUMN reward_gift int AFTER reward_org_client;
#DWS 04.26.13 M0001082: Rewards points awarded for purchase not negated when GC is voided

UPDATE org_parm SET value = REPLACE(value, 'tomorrow ', '') WHERE type='Booking' AND parm='booking_reminder';
UPDATE email_marketing SET headline = REPLACE(headline, 'tomorrow ', ''), body = REPLACE(body, 'tomorrow ', ''), narrative = REPLACE(narrative, 'tomorrow ', ''), permalink = REPLACE(permalink, '-tomorrow', '') WHERE id='booking_reminder';
#DWS 5.6.13 M0000953: Need 48 hour booking reminder

ALTER TABLE queue_social ADD COLUMN default_sm_posts int(11) NULL AFTER org;
ALTER TABLE queue_social ADD COLUMN default_sm_posts_event int(11) NULL AFTER default_sm_posts;
#MGK 05.08.13 M0001038 Copying from auto_orgs

INSERT INTO org_parm (org, type, parm, value) VALUES (409, "Stripe", "client_id", "ca_1ihl9Mtn8JDdnM3DjAXvkroEbCA0CT5G");
INSERT INTO org_parm (org, type, parm, value) VALUES (409, "Stripe", "boomtime_sk", "sk_live_D3bf7YF9y2DX5srYXvgI8Sbt");
INSERT INTO org_parm (org, type, parm, value) VALUES (409, "Stripe", "boomtime_pk", "pk_live_v9GqLAPj0i80RxeXk2ontQiC");
INSERT INTO org_parm (org, type, parm, value) VALUES (409, "Stripe", "token_uri", "https://connect.stripe.com/oauth/token");
INSERT INTO org_parm (org, type, parm, value) VALUES (409, "Stripe", "authorize_uri", "https://connect.stripe.com/oauth/authorize");
INSERT INTO org_parm (org, type, parm, value) VALUES (13, "Stripe", "client_id", "ca_1ihl9Mtn8JDdnM3DjAXvkroEbCA0CT5G");
INSERT INTO org_parm (org, type, parm, value) VALUES (13, "Stripe", "boomtime_sk", "sk_live_D3bf7YF9y2DX5srYXvgI8Sbt");
INSERT INTO org_parm (org, type, parm, value) VALUES (13, "Stripe", "boomtime_pk", "pk_live_v9GqLAPj0i80RxeXk2ontQiC");
INSERT INTO org_parm (org, type, parm, value) VALUES (13, "Stripe", "token_uri", "https://connect.stripe.com/oauth/token");
INSERT INTO org_parm (org, type, parm, value) VALUES (13, "Stripe", "authorize_uri", "https://connect.stripe.com/oauth/authorize");
INSERT INTO org_parm (org, type, parm, value) VALUES (2646, "Stripe", "client_id", "ca_1ihl9Mtn8JDdnM3DjAXvkroEbCA0CT5G");
INSERT INTO org_parm (org, type, parm, value) VALUES (2646, "Stripe", "boomtime_sk", "sk_live_D3bf7YF9y2DX5srYXvgI8Sbt");
INSERT INTO org_parm (org, type, parm, value) VALUES (2646, "Stripe", "boomtime_pk", "pk_live_v9GqLAPj0i80RxeXk2ontQiC");
INSERT INTO org_parm (org, type, parm, value) VALUES (2646, "Stripe", "token_uri", "https://connect.stripe.com/oauth/token");
INSERT INTO org_parm (org, type, parm, value) VALUES (2646, "Stripe", "authorize_uri", "https://connect.stripe.com/oauth/authorize");
INSERT INTO org_parm (org, type, parm, value) VALUES (2963, "Stripe", "client_id", "ca_1ihl9Mtn8JDdnM3DjAXvkroEbCA0CT5G");
INSERT INTO org_parm (org, type, parm, value) VALUES (2963, "Stripe", "boomtime_sk", "sk_live_D3bf7YF9y2DX5srYXvgI8Sbt");
INSERT INTO org_parm (org, type, parm, value) VALUES (2963, "Stripe", "boomtime_pk", "pk_live_v9GqLAPj0i80RxeXk2ontQiC");
INSERT INTO org_parm (org, type, parm, value) VALUES (2963, "Stripe", "token_uri", "https://connect.stripe.com/oauth/token");
INSERT INTO org_parm (org, type, parm, value) VALUES (2963, "Stripe", "authorize_uri", "https://connect.stripe.com/oauth/authorize");
INSERT INTO org_parm (org, type, parm, value) VALUES (5674, "Stripe", "client_id", "ca_1ihl9Mtn8JDdnM3DjAXvkroEbCA0CT5G");
INSERT INTO org_parm (org, type, parm, value) VALUES (5674, "Stripe", "boomtime_sk", "sk_live_D3bf7YF9y2DX5srYXvgI8Sbt");
INSERT INTO org_parm (org, type, parm, value) VALUES (5674, "Stripe", "boomtime_pk", "pk_live_v9GqLAPj0i80RxeXk2ontQiC");
INSERT INTO org_parm (org, type, parm, value) VALUES (5674, "Stripe", "token_uri", "https://connect.stripe.com/oauth/token");
INSERT INTO org_parm (org, type, parm, value) VALUES (5674, "Stripe", "authorize_uri", "https://connect.stripe.com/oauth/authorize");
INSERT INTO org_parm (org, type, parm, value) VALUES (7400, "Stripe", "client_id", "ca_1ihl9Mtn8JDdnM3DjAXvkroEbCA0CT5G");
INSERT INTO org_parm (org, type, parm, value) VALUES (7400, "Stripe", "boomtime_sk", "sk_live_D3bf7YF9y2DX5srYXvgI8Sbt");
INSERT INTO org_parm (org, type, parm, value) VALUES (7400, "Stripe", "boomtime_pk", "pk_live_v9GqLAPj0i80RxeXk2ontQiC");
INSERT INTO org_parm (org, type, parm, value) VALUES (7400, "Stripe", "token_uri", "https://connect.stripe.com/oauth/token");
INSERT INTO org_parm (org, type, parm, value) VALUES (7400, "Stripe", "authorize_uri", "https://connect.stripe.com/oauth/authorize");
INSERT INTO org_parm (org, type, parm, value) VALUES (7464, "Stripe", "client_id", "ca_1ihl9Mtn8JDdnM3DjAXvkroEbCA0CT5G");
INSERT INTO org_parm (org, type, parm, value) VALUES (7464, "Stripe", "boomtime_sk", "sk_live_D3bf7YF9y2DX5srYXvgI8Sbt");
INSERT INTO org_parm (org, type, parm, value) VALUES (7464, "Stripe", "boomtime_pk", "pk_live_v9GqLAPj0i80RxeXk2ontQiC");
INSERT INTO org_parm (org, type, parm, value) VALUES (7464, "Stripe", "token_uri", "https://connect.stripe.com/oauth/token");
INSERT INTO org_parm (org, type, parm, value) VALUES (7464, "Stripe", "authorize_uri", "https://connect.stripe.com/oauth/authorize");
INSERT INTO org_parm (org, type, parm, value) VALUES (7772, "Stripe", "client_id", "ca_1ihl9Mtn8JDdnM3DjAXvkroEbCA0CT5G");
INSERT INTO org_parm (org, type, parm, value) VALUES (7772, "Stripe", "boomtime_sk", "sk_live_D3bf7YF9y2DX5srYXvgI8Sbt");
INSERT INTO org_parm (org, type, parm, value) VALUES (7772, "Stripe", "boomtime_pk", "pk_live_v9GqLAPj0i80RxeXk2ontQiC");
INSERT INTO org_parm (org, type, parm, value) VALUES (7772, "Stripe", "token_uri", "https://connect.stripe.com/oauth/token");
INSERT INTO org_parm (org, type, parm, value) VALUES (7772, "Stripe", "authorize_uri", "https://connect.stripe.com/oauth/authorize");
INSERT INTO org_parm (org, type, parm, value) VALUES (7836, "Stripe", "client_id", "ca_1ihl9Mtn8JDdnM3DjAXvkroEbCA0CT5G");
INSERT INTO org_parm (org, type, parm, value) VALUES (7836, "Stripe", "boomtime_sk", "sk_live_D3bf7YF9y2DX5srYXvgI8Sbt");
INSERT INTO org_parm (org, type, parm, value) VALUES (7836, "Stripe", "boomtime_pk", "pk_live_v9GqLAPj0i80RxeXk2ontQiC");
INSERT INTO org_parm (org, type, parm, value) VALUES (7836, "Stripe", "token_uri", "https://connect.stripe.com/oauth/token");
INSERT INTO org_parm (org, type, parm, value) VALUES (7836, "Stripe", "authorize_uri", "https://connect.stripe.com/oauth/authorize");
INSERT INTO org_parm (org, type, parm, value) VALUES (8324, "Stripe", "client_id", "ca_1ihl9Mtn8JDdnM3DjAXvkroEbCA0CT5G");
INSERT INTO org_parm (org, type, parm, value) VALUES (8324, "Stripe", "boomtime_sk", "sk_live_D3bf7YF9y2DX5srYXvgI8Sbt");
INSERT INTO org_parm (org, type, parm, value) VALUES (8324, "Stripe", "boomtime_pk", "pk_live_v9GqLAPj0i80RxeXk2ontQiC");
INSERT INTO org_parm (org, type, parm, value) VALUES (8324, "Stripe", "token_uri", "https://connect.stripe.com/oauth/token");
INSERT INTO org_parm (org, type, parm, value) VALUES (8324, "Stripe", "authorize_uri", "https://connect.stripe.com/oauth/authorize");
#Stripe keys for brand orgs
#END 5.20.2013 UPDATE

#BEGIN 5.29.2013 UPDATE
ALTER TABLE book ADD COLUMN booking_prepaid decimal(12,2);
#DWS 5.7.13 M0001094: Booking and Rewards: need to indicate that a booking is being paid by a GC
#END 5.29.2013 UPDATE

#BEGIN 6.13.2013 UPDATE
ALTER TABLE billing ADD COLUMN billing_hold_date date NULL AFTER billing_hold; 
#MGK 06.11.13 "Billing Enhancements" Add billing_hold_date column
#END 6.13.2013 UPDATE

#BEGIN 6.17.2013 UPDATE
ALTER TABLE billing ADD COLUMN billing_hold_date date NULL AFTER billing_hold;
#MGK 06.11.13 "Billing Enhancements" Add billing_hold_date column
#END 6.13.2013 UPDATE

#BEGIN 6.17.2013 UPDATE
ALTER TABLE org_type_content ADD COLUMN title text AFTER content, ADD COLUMN force_content tinyint NOT NULL DEFAULT 0;
ALTER TABLE org_type_content ADD primary key (org_type, page_id);
ALTER TABLE org_content ADD COLUMN title text AFTER content, ADD COLUMN force_content tinyint NOT NULL DEFAULT 0;
ALTER TABLE org_content ADD primary key (org, page_id);

INSERT INTO org_content (org, page_id, content, force_content) VALUES (2850, 'home', '<h1>Welcome to {short_name}!</h1>
<div boomtime="photo_right" id="anchor_2" max_width="150"></div>
<p>You can start with {booking_link}, purchase an <a href="gift">Instant Gift Certificate</a>
or <a href="contact">Contact Us</a> for more information.<br>
</p>{event(1)}{event(2)}{event(4)}', 1);
INSERT INTO org_content (org, page_id, content, title, force_content) VALUES (2850, 'menu', '<h1>Menu</h1>
<span class="mceNonEditable">{menu}</span>', 'Menu', 1);
INSERT INTO org_content (org, page_id, content, title) VALUES (2850, 'schedule', '<span class="mceNonEditable">{request}</span>', 'Reservations');
#DWS 6.10.13 M0001130: Coverboom orgs still have spa-oriented remnants that negatively affect functionality

ALTER TABLE website_widget ADD COLUMN carousel_items int(11);
#DWS 5.23.13 M0001076: Blog widget carousel

INSERT INTO part (org, part_id, content) VALUES (3, 'email_signup', '<h1>Thanks!</h1><p>Thank you for signing up to {short_name}!</p>');
INSERT INTO part (org, part_id, content) VALUES (3, 'opt_noconfirm', '<h1>Please complete your profile</h1>');
#DWS 6.11.13 M0001145: Do not require opt in for SpaEmergency org only

ALTER TABLE website_widget ADD COLUMN event_headline_items int(11), ADD COLUMN event_opt_headline varchar(100);
#DWS 6.14.13 0001147: Event Headline Widget
#END 6.17.2013 UPDATE

#BEGIN 07.29.13 UPDATE
ALTER TABLE gift_promo ADD COLUMN opt_message text;
#DWS 5.31.13 M0001123: Allow one-off emails to a single client for promotions, thank-yous, giveaways

ALTER TABLE `sevence`.`resource` ADD COLUMN `client_address` INT(11) NULL DEFAULT NULL;
ALTER TABLE `sevence`.`bookday_prof` ADD COLUMN `client_address` INT(11) NULL  AFTER `prof`, DROP PRIMARY KEY, ADD PRIMARY KEY (`prof`, `client_address`, `date`) ;
ALTER TABLE `sevence`.`request` ADD COLUMN `client_address` INT(11) NULL  AFTER `org_tran` ;
#KA 5.8.2013 client_address field for rooms, bookday_prof, and appointment request

ALTER TABLE `sevence`.`book` ADD COLUMN `request_id` INT(11) NOT NULL  AFTER `reward_refer_gift_amount` ;
#RD 5.20.13 Mantis ID 1102, insert request id for book in relation to request table

ALTER TABLE `sevence`.`org_book` ADD COLUMN `show_avail_times` TINYINT(1) NOT NULL DEFAULT '0';
ALTER TABLE `sevence`.`org_book` ADD COLUMN `allow_prof_selection` TINYINT(1) NOT NULL DEFAULT '0';
ALTER TABLE `sevence`.`request` ADD COLUMN `prof` INT(11) NOT NULL DEFAULT 0  AFTER `client_address` ;
#RC 5.21.13 ADD new fields for booking settings

CREATE  TABLE `sevence`.`prof_service` (
  `prof_service` INT(11) NOT NULL AUTO_INCREMENT ,
  `service` INT(11) NOT NULL ,
  `prof` INT(11) NOT NULL ,
  PRIMARY KEY (`prof_service`) ,
  INDEX `service_idx` (`service` ASC) ,
  INDEX `prof_idx` (`prof` ASC) ,
  CONSTRAINT `prof`
    FOREIGN KEY (`prof` )
    REFERENCES `sevence`.`prof` (`prof` )
    ON DELETE CASCADE
    ON UPDATE NO ACTION,
  CONSTRAINT `service`
    FOREIGN KEY (`service` )
    REFERENCES `sevence`.`service` (`service` )
    ON DELETE CASCADE
    ON UPDATE NO ACTION);
#RD 5.29.13 Mantis ID 1125, ADD new table prof_service for professional services offered

CREATE TABLE `resource_services` (
  `resource_services` int(11) NOT NULL AUTO_INCREMENT,
  `resource` int(11) DEFAULT NULL,
  `service` int(11) DEFAULT NULL,
  PRIMARY KEY (`resource_services`),
  KEY `resource_idx` (`resource`),
  KEY `service_idx` (`service`),
  CONSTRAINT `resource` FOREIGN KEY (`resource`) REFERENCES `resource` (`resource`) ON DELETE CASCADE ON UPDATE NO ACTION,
  CONSTRAINT `service_fk1` FOREIGN KEY (`service`) REFERENCES `service` (`service`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
#RC 5.29.13 Mantis ID 1125, ADD new table resource_services for resource(room) services offered

ALTER TABLE `sevence`.`book` ADD COLUMN `block_prof` TINYINT(1) NOT NULL DEFAULT '0';
ALTER TABLE `sevence`.`book` ADD COLUMN `block_resource` TINYINT(1) NOT NULL DEFAULT '0';
#RC 6.4.13 Mantis ID 1136, ADD two new fields in book table for prof or resource off time

ALTER TABLE `sevence`.`org_book` ADD COLUMN `last_appointment` INT(11) NOT NULL DEFAULT '0'  AFTER `allow_prof_selection` ;
#RD 6.5.13 Mastis ID 740, Add new field last_appointment for org_book

ALTER TABLE `sevence`.`book` ADD COLUMN `overtime` TINYINT(1) NOT NULL DEFAULT 0  AFTER `block_resource` ;
#KA 6.11.13 M0000740: Last appointment and working outside of standard hours

ALTER TABLE `sevence`.`org_book` ADD COLUMN `book_direct_to_calendar` TINYINT(1) NOT NULL DEFAULT '0' AFTER allow_prof_selection;
#RC 5.21.13 ADD new field for org_book table for booking settings

CREATE TABLE `location_services_except` (
  `location_services_except` int(11) NOT NULL AUTO_INCREMENT,
  `client_address` int(11) DEFAULT NULL,
  `services` int(11) DEFAULT NULL,
  PRIMARY KEY (`location_services_except`)
)
#RC 6.24.13 CREATE new table for location service exception

ALTER TABLE `sevence`.`org_book` ADD COLUMN `time_buffer` INT(11) NOT NULL DEFAULT '0'  AFTER `last_appointment` ;
#RD 5.24.13 M0000182: ADD new field for org_book. online booking time buffer

ALTER TABLE `sevence`.`prof` ADD COLUMN `seniority` DECIMAL(4,2) NOT NULL DEFAULT '1.00'  AFTER `send_sms` ;
#RD 7.11.13 M0001177: ADD new priority number for profesional

ALTER TABLE `sevence`.`service` ADD COLUMN `addon` TINYINT(1) NULL DEFAULT '0'  AFTER `hide` ;
#RD 07.22.13 M0000723: Additional field for service that are addons.

ALTER TABLE `sevence`.`book_color` ADD COLUMN `bg_title_unconfirm` VARCHAR(7) NULL DEFAULT '#ff00ff'  AFTER `text_upcoming` , ADD COLUMN `bg_note_unconfirm` VARCHAR(7) NULL DEFAULT '#ff56ff'  AFTER `bg_title_unconfirm` , ADD COLUMN `text_unconfirm` VARCHAR(7) NULL DEFAULT '#FFFFFF'  AFTER `bg_note_unconfirm` ;
UPDATE `sevence`.`book_color` SET `book_css`=' #book_grid .book_slot {      color: <?text?>; }  #book_grid .book_slot .book_slot_title {      background: <?bg_title?>;      border-bottom: 1px solid <?text?>; }  #book_grid .book_slot .book_slot_note {      background: <?bg_note?>; }  #book_grid .book_slot.checked_in {      color: <?text_checked_in?>; }  #book_grid .book_slot.checked_in .book_slot_title {      background: <?bg_title_checked_in?>;      border-bottom: 1px solid <?text_checked_in?>; }  #book_grid .book_slot.checked_in .book_slot_note {      background: <?bg_note_checked_in?>; }  #book_grid .book_slot.paid {      color: <?text_paid?>; }  #book_grid .book_slot.paid .book_slot_title {      background: <?bg_title_paid?>;      border-bottom: 1px solid <?text_paid?>; }  #book_grid .book_slot.paid .book_slot_note {      background: <?bg_note_paid?>; }  #book_grid .book_slot.missing {      color: <?text_missing?>; }  #book_grid .book_slot.missing .book_slot_title {      background: <?bg_title_missing?>;      border-bottom: 1px solid <?text_missing?>; }  #book_grid .book_slot.missing .book_slot_note {      background: <?bg_note_missing?>; }  #book_grid .book_slot.upcoming {      color: <?text_upcoming?>; }  #book_grid .book_slot.upcoming .book_slot_title {      background: <?bg_title_upcoming?>;      border-bottom: 1px solid <?text_upcoming?>; }  #book_grid .book_slot.upcoming .book_slot_note {      background: <?bg_note_upcoming?>; } #book_grid .book_slot.unconfirm {      color: <?text_unconfirm?>; }  #book_grid .book_slot.unconfirm .book_slot_title {      background: <?bg_title_unconfirm?>;      border-bottom: 1px solid <?text_unconfirm?>; }  #book_grid .book_slot.unconfirm .book_slot_note {      background: <?bg_note_unconfirm?>; } ' WHERE `org`='3';
ALTER TABLE `sevence`.`org_book` ADD COLUMN `book_to_calendar_with_confirmation` TINYINT(1) NOT NULL DEFAULT 0  AFTER `book_direct_to_calendar` ;
ALTER TABLE `sevence`.`book` ADD COLUMN `book_confirm` TINYINT(1) NULL DEFAULT NULL  AFTER `overtime` ;
#RC 07.23.13 M0001189: Additional fields and update book_css field for book_color table, Additional field for org_book as well in book tables

ALTER TABLE org_gift_design ADD COLUMN promo_only tinyint NOT NULL default 0 AFTER popularity;
#DWS 6.26.13 M0000252 Promo GC designs.

INSERT INTO `email_marketing` (`org`, `type`, `id`, `active`, `name`, `subject`, `headline`, `narrative`, `body`, `email_cycle`, `permalink`) VALUES
(3, 1, 'appt_request', 1, 'appointment request', 'Appointment Request', 'Appointment Request', 'Appointment Request\r\n\r\n{location_info}\r\n\r\nThank you! We''ll contact you shortly with confirmation of your appointment.\r\nAppointment for:\r\n\r\n{client} {order_table}\r\n\r\n{cancellation_policy}\r\n\r\n', 'Appointment Request<br />\r\n<br />\r\n{location_info}<br />\r\n<br />\r\nThank you! We&#039;ll contact you shortly with confirmation of your appointment.<br />\r\nAppointment for:<br />\r\n<br />\r\n{client} {order_table}<br />\r\n<br />\r\n{cancellation_policy}<br />\r\n<br />\r\n', 1, 'appointment-request'),
(3, 1, 'propose_newtime', 1, 'propose newtime', 'Appointment Request: New Time Proposal', 'New Time Proposal', 'Thank you for booking your appointment with {org_name}\r\n\r\nUnfortunately, the time you requested is not available. Would the following time work?\r\n\r\n{services}\r\n\r\n{propose_newtime}\r\n\r\n{cancellation_policy}', 'Thank you for booking your appointment with {org_name}<br />\r\n<br />\r\nUnfortunately, the time you requested is not available. Would the following time work?<br />\r\n<br />\r\n{services}<br />\r\n<br />\r\n{propose_newtime}<br />\r\n<br />\r\n{cancellation_policy}', 1, 'appointment-request-new-time-proposal'),
(3, 1, 'confirm_appt', 1, 'confirm appointment', 'Appointment Confirmation', 'Appointment Confirmation', 'Thank you for booking your appointment with {org_name}\r\n\r\nWe have you confirmed for:\r\n\r\n{services}\r\n\r\n{cancellation_policy}', 'Thank you for booking your appointment with {org_name}<br />\r\n<br />\r\nWe have you confirmed for:<br />\r\n<br />\r\n{services}<br />{propose_newtime}<br />\r\n<br />\r\n{cancellation_policy}', 1, 'appointment-confirmation');
#RC 5.16.2013 Mantis ID 1103, insert new email IDs for appointment_request, confirm_appointment and propose_newtime, 6.17.2013 adding {org_head} tag for email content of appointment request and confirm request

UPDATE `sevence`.`email_marketing` SET `body`=' {org_head} <p>Thank you for booking your appointment with {org_name}</p> {details} {services} <p>{propose_newtime}</p> <p>Appointments are held  with a credit card. At the time of service, you can alternatively use a  gift certificate. The full service fee is charged for cancellations or  no-shows without 24 hour notice.</p>' WHERE `org`='3' AND id = 'confirm_appt';
#RC 07.25.13 M0001189: Modify body field layout in email_marketing table.
#END 07.28.13

#08.14.13 UPDATE BEGIN
ALTER TABLE `sevence`.`prof` ADD COLUMN `booking_notification` TINYINT(1) NULL DEFAULT 1  AFTER `seniority` ;
INSERT INTO `email_marketing` (`org`, `type`, `id`, `active`, `name`, `subject`, `headline`, `narrative`, `body`, `email_cycle`, `permalink`,`email_design`,`editor`) VALUES
(3, 1, 'appt_alert', 1, 'appointment alert', 'Appointment {update_status}Alert', 'Appointment Alert','', '<p>Appointment #: {appt_num}</p><p>Spa: {company_name}</p></p><p> Date: {appointment_date}</p><p>Client: {client_name}</p>', 1, 'appointment-alert',121,1);
#KA 08.05.2013 M1217 Email and text professional when booking is scheduled
#08.14.13 UPDATE END

#09.03.13 UPDATE BEGIN
ALTER TABLE `sevence`.`org_book` ADD COLUMN `require_cc` TINYINT(1) NOT NULL DEFAULT '1';
#RC 8.16.2013 Mantis ID 802 ADD NEW field in org_book table for Credit Card Settings in basic.
#09.03.13 UPDATE END

#09.15.13 UPDATE BEGIN
ALTER TABLE client ADD COLUMN stripe_cust_for_booking VARCHAR( 40 ) NULL AFTER stripe_customer;
#MGK 7.24.2013: stripeProcessing - Add a column to store customer object id's from stripe but is only used for booking.

ALTER TABLE `sevence`.`org` ADD COLUMN `goods_tax` DECIMAL(12,4) NULL DEFAULT '0.0000'  AFTER `service_tax` ;
ALTER TABLE `sevence`.`service` ADD COLUMN `tax_type` TINYINT(1) NULL DEFAULT '1'  AFTER `addon` , ADD COLUMN `tax_rate` DECIMAL(12,4) NULL DEFAULT '0.0000'  AFTER `tax_type` ;
ALTER TABLE `sevence`.`service_cat` ADD COLUMN `tax_type` TINYINT(1) NULL DEFAULT '1'  AFTER `sort` , ADD COLUMN `tax_rate` DECIMAL(12,4) NULL DEFAULT '0.0000'  AFTER `tax_type` ;
#RC 08.13.13 M000157: ADD a column goods_tax to org table. ADD two new columns for service_cat table same with service table.

#INVOICE TABLE
CREATE TABLE `invoice` (
  `invoice` int(11) NOT NULL AUTO_INCREMENT,
  `org` int(11) NOT NULL,
  `book` int(11) NOT NULL,
  `client_address` int(11) NOT NULL,
  `paid_date` DATETIME DEFAULT NULL,
  `org_client` int(11) NOT NULL,
  `checkout_prof` int(11) NOT NULL,
  `subtotal` DECIMAL(12,2) NOT NULL,
  `discount_type` TINYINT(1) DEFAULT NULL,
  `discount` DECIMAL(12,2) DEFAULT 0.00,
  `discount_percent` DECIMAL(12,2) DEFAULT 0.00,
  `tax` DECIMAL(12,2) DEFAULT 0.00,
  `gratuity_type` TINYINT(1) DEFAULT NULL,
  `gratuity` DECIMAL(12,2) DEFAULT 0.00,
  `gratuity_percent` DECIMAL(12,2) DEFAULT 0.00,
  `invoice_total` DECIMAL(12,2) NOT NULL,
  `payments_total` DECIMAL(12,2) DEFAULT 0.00,
  `balance` DECIMAL(12,2) DEFAULT 0.00,
  `note` TEXT DEFAULT NULL,
  `processed` TINYINT(1) DEFAULT 0,
  `processed_date` DATETIME NULL,
  `created_at` DATETIME NOT NULL,
  `updated_at` DATETIME NOT NULL,
  PRIMARY KEY (`invoice`),
  CONSTRAINT `invoice_org_fk` FOREIGN KEY (`org`) REFERENCES `org` (`org`)
);

#INVOICE LINE
CREATE TABLE `invoice_line` (
  `invoice_line` int(11) NOT NULL AUTO_INCREMENT,
  `invoice_id` int(11) NOT NULL,
  `qty` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `service_option_id` int(11) DEFAULT NULL,
  `service_option_name` VARCHAR(50) DEFAULT NULL,
  `service_cat_id` int(11) DEFAULT NULL,
  `service_cat_name` VARCHAR(50) DEFAULT NULL,
  `package` TINYINT(1) DEFAULT 0,
  `book_slot` int(11) DEFAULT NULL,
  `service_prof` int(11) DEFAULT NULL,
  `name_description` TEXT NOT NULL,
  `unit_price` DECIMAL(12,2) NOT NULL,
  `discount_type` TINYINT(1) DEFAULT NULL,
  `discount_percent` DECIMAL(12,2) DEFAULT 0.00,
  `discount` DECIMAL(12,2) DEFAULT 0.00,
  `taxable` TINYINT(1) DEFAULT NULL,
  `tax_rate` DECIMAL(12,4) DEFAULT 0.00,
  `tax` DECIMAL(12,2) DEFAULT 0.00,
  `line_amount` DECIMAL(12,2) NOT NULL,
  PRIMARY KEY (`invoice_line`),
  CONSTRAINT `invoice_line_invoice_fk` FOREIGN KEY (`invoice_id`) REFERENCES `invoice` (`invoice`)
);

#INVOICE LINE PACKAGE DETAILS
CREATE TABLE `invoice_line_pkg_detail` (
  `invoice_line_pkg_detail` int(11) NOT NULL AUTO_INCREMENT,
  `invoice_line_id` int(11) NOT NULL,
  `package_service_option` int(11) DEFAULT NULL,
  `qty` int(11) NOT NULL,
  `service_option_id` int(11) DEFAULT NULL,
  `service_option_name` VARCHAR(50) DEFAULT NULL,
  `service_cat_id` int(11) DEFAULT NULL,
  `service_cat_name` VARCHAR(50) DEFAULT NULL,
  `book_slot` int(11) DEFAULT NULL,
  `service_prof` int(11) DEFAULT NULL,
  `name_description` TEXT NOT NULL,
  `unit_price` DECIMAL(12,2) NOT NULL,
  PRIMARY KEY (`invoice_line_pkg_detail`),
  CONSTRAINT `invoice_line_pkg_details_invoice_line_fk` FOREIGN KEY (`invoice_line_id`) REFERENCES `invoice_line` (`invoice_line`)
);

#PAYMENT
CREATE TABLE `payment` (
  `payment` int(11) NOT NULL AUTO_INCREMENT,
  `invoice_id` int(11) NOT NULL,
  `payment_type` TINYINT(1) NOT NULL,
  `payment_amount` DECIMAL(12,2) NOT NULL DEFAULT 0.00,
  `payment_date` DATETIME NOT NULL,
  `stripe_charge_id` VARCHAR(45) DEFAULT NULL,
  `check_number` VARCHAR(20) DEFAULT NULL,
  `gift` int(11) DEFAULT NULL,
  PRIMARY KEY (`payment`),
  CONSTRAINT `payment_invoice_fk` FOREIGN KEY (`invoice_id`) REFERENCES `invoice` (`invoice`)
);
#MGK 8.18.2013: POS - M0001195: Stripe checkout from Booking Part I

#INVOICE PROMOTION
CREATE TABLE `invoice_promotion` (
  `invoice_promotion` int(11) NOT NULL AUTO_INCREMENT,
  `invoice_id` int(11) NOT NULL,
  `gift_promo` int(11) NOT NULL,
  PRIMARY KEY (`invoice_promotion`),
  CONSTRAINT `promotion_invoice_fk` FOREIGN KEY (`invoice_id`) REFERENCES `invoice` (`invoice`)
);
#MGK 8.26.2013: POS - M0001195: Stripe checkout from Booking Part I

ALTER TABLE org ADD checkout tinyint(1) NOT NULL DEFAULT 0 after gift_bcc;
#MGK 8.30.2013: M0001282: "Checkout from Booking"

ALTER TABLE invoice_promotion ADD offer_id VARCHAR(20) DEFAULT NULL AFTER gift_promo;
#MGK 7.5.2013: M0001261: Add a save button to the invoice form. Easier to display past saved state.

ALTER TABLE payment ADD gift_id VARCHAR(20) DEFAULT NULL AFTER gift;
#MGK 7.5.2013: M0001261: Add a save button to the invoice form. Easier to display past saved state.
#09.15.13 UPDATE END

#10.08.13 UPDATE BEGIN
ALTER TABLE `sevence`.`service` ADD COLUMN `processing_time` INT(11) NOT NULL DEFAULT '0'  AFTER `tax_rate` ;
#RC 9.12.13 Mantis 1308: ADD new field for service table
#10.08.13 UPDATE END

#11.17.13 UPDATE BEGIN
ALTER TABLE `sevence`.`org_book` ADD COLUMN `appt_request_daysout` INT(5) NOT NULL DEFAULT '30'  AFTER `require_cc` ;
#RC 10.23.13 Mantis 1383: ADD new field for org_book table

ALTER TABLE `sevence`.`template` ADD COLUMN `superadmin_only` TINYINT(1) NOT NULL DEFAULT '0'  AFTER `background_photo_css` ;
#RC 10.23.13 Mantis 1343: ADD new field for template table

ALTER TABLE `sevence`.`client_address` ADD COLUMN `hide` TINYINT(1) NOT NULL DEFAULT '0'  AFTER `longitude` ;
#RC 10.23.13 Mantis 1387: ADD new field for client_address table

ALTER TABLE `sevence`.`auto_article` ADD COLUMN `draft` TINYINT(1) NOT NULL DEFAULT '1'  AFTER `offering9` ;
UPDATE auto_article SET draft = 0;
#RC 10.28.13 Mantis 1394: ADD new field for auto_article table
#11.17.13 UPDATE END

#11.27.14 ILLICIT THANKSGIVING UPDATE BEGIN
ALTER TABLE gift_type MODIFY column last_gift_id BIGINT(20)
#SLOW 11.28.13 0001453: Support for larger gift IDs
#11.27.14 ILLICIT THANKSGIVING UPDATE END

#1.27.14 UPDATE BEGIN
CREATE TABLE `org_mobile` (
  `org` int(11) NOT NULL,
  `contact_update` datetime DEFAULT NULL,
  `content_update` datetime DEFAULT NULL,
  `photo_update` datetime DEFAULT NULL,
  `service_update` datetime DEFAULT NULL,
  PRIMARY KEY (`org`),
  CONSTRAINT `org_mobile_ibfk_1` FOREIGN KEY (`org`) REFERENCES `org` (`org`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `org_mobile_photo` (
  `org` int(11) NOT NULL,
  `sort` tinyint(4) NOT NULL,
  `photo` int(11) NOT NULL,
  `photo_filename` varchar(100) NOT NULL,
  KEY `org` (`org`),
  KEY `photo` (`photo`),
  CONSTRAINT `org_mobile_photo_ibfk_2` FOREIGN KEY (`photo`) REFERENCES `photo` (`photo`),
  CONSTRAINT `org_mobile_photo_ibfk_1` FOREIGN KEY (`org`) REFERENCES `org` (`org`)
);
#DWS 04.18.13 M0001064:  Mobile API and fuse setup for the Home Screen

CREATE  TABLE `sevence`.`org_mobile_website` (
  `org` INT(11) NOT NULL ,
  `logo_type` INT(11) NULL DEFAULT 0 ,
  `logo_text` VARCHAR(45) NULL ,
  `text_color` VARCHAR(45) NULL ,
  `logo_filename` VARCHAR(45) NULL ,
  `logo_photo` INT(11) NULL ,
  PRIMARY KEY (`org`) );

CREATE TABLE `org_mobile_logo` (
  `logo` int(11) NOT NULL AUTO_INCREMENT,
  `org` int(11) NOT NULL,
  `logo_type` int(11) DEFAULT '0',
  `logo_text` varchar(45) DEFAULT NULL,
  `logo_color` varchar(45) DEFAULT '#000000',
  `logo_font` varchar(45) DEFAULT NULL,
  `logo_font_size` int(11) DEFAULT '12',
  `logo_file` varchar(255) DEFAULT NULL,
  `logo_photo` int(11) DEFAULT NULL,
  PRIMARY KEY (`logo`),
  UNIQUE KEY `org_UNIQUE` (`org`)
) ;
#RD 08.05.13 M0001064: Added Mobile logo Setup

ALTER TABLE `sevence`.`org_mobile` ADD COLUMN `logo_update` DATETIME NULL DEFAULT NULL  AFTER `service_update` ;
#RD 08.28.2013 Added logo_update field in org_mobile

ALTER TABLE `sevence`.`org` ADD COLUMN `shortername` VARCHAR(45) NULL  AFTER `short_name` ;
#RD 09.23.2013 Added shortername field

CREATE  TABLE `sevence`.`org_mobile_theme` (
  `org` INT NOT NULL ,
  `theme_color_1` VARCHAR(45) NULL ,
  `theme_color_2` VARCHAR(45) NULL ,
  PRIMARY KEY (`org`) );

ALTER TABLE `sevence`.`org_mobile_theme` CHANGE COLUMN `theme_color_1` `theme_color_1` VARCHAR(45) NULL DEFAULT '#000000'  , CHANGE COLUMN `theme_color_2` `theme_color_2` VARCHAR(45) NULL DEFAULT '#000000'  ;

ALTER TABLE `sevence`.`org_mobile` ADD COLUMN `theme_update` DATETIME NULL DEFAULT NULL  AFTER `logo_update` ;
#RD 09.23.2013 Added org_mobile theme

CREATE  TABLE `sevence`.`org_mobile_service` (
  `service_cat` INT NOT NULL ,
  `org` INT NULL ,
  `photo` INT NULL ,
  `photo_filename` VARCHAR(45) NULL ,
  PRIMARY KEY (`service_cat`) );

CREATE  TABLE `sevence`.`org_mobile_icon` (
  `org` INT NOT NULL ,
  `photo` VARCHAR(45) NULL ,
  `photo_filename` VARCHAR(45) NULL ,
  PRIMARY KEY (`org`) );

ALTER TABLE `sevence`.`org_mobile_icon` CHANGE COLUMN `photo` `photo` INT(11) NULL DEFAULT NULL  ;

ALTER TABLE `sevence`.`org_mobile` ADD COLUMN `icon_update` DATETIME NULL  AFTER `theme_update` ;
#RD 09.30.2013 Added org mobile set icons

ALTER TABLE `sevence`.`org_mobile_theme` ADD COLUMN `font_color_primary` VARCHAR(45) NULL DEFAULT '#000000'  AFTER `theme_color_2` , ADD COLUMN `font_color_secondary` VARCHAR(45) NULL DEFAULT '#000000'  AFTER `font_color_primary` ;
#RD Mantis 1417 11.06.2013 : add field app_access for firs time non-super admin accessed

ALTER TABLE `sevence`.`org_mobile` ADD COLUMN `app_access` TINYINT NOT NULL DEFAULT 0  AFTER `icon_update` ;

INSERT INTO `template` (`type`,`name`,`content`,`no_sidebar_css`,`tab`,`hide`,`home_page`,`background_photo`,`background_photo_css`,`superadmin_only`) VALUES (3,'Mobile App','.btButton{font-family:\'lucida grande\',tahoma,verdana,arial,sans-serif;color:#333;cursor:pointer;display:inline-block;font-size:13px;line-height:18px;font-weight:bold;padding:2px 6px;text-align:center;text-decoration:none;vertical-align:top;white-space:nowrap;background-color:#f9f9f9;border:1px solid #999;border-bottom-color:#888;-webkit-box-shadow:0 1px 0 rgba(0, 0, 0, .1);border-color:#a5a5a5;border-color:rgba(0, 0, 0, .35)}	\r\n.btfirstItem{border-top-left-radius:3px;border-bottom-left-radius:3px}\r\n.btnextItem{margin-left:-3px;border-top-right-radius:3px;border-bottom-right-radius:3px}\r\n.btSelected{background-color:#ddd;color:#333;border-bottom-color:#999;-webkit-box-shadow:0 1px 0 rgba(0, 0, 0, .05)}\r\n\r\n.dtstart{display:none;}\r\n.dtend{display:none;}\r\n.news_date{display:none;}\r\n.summary{display:none;}\r\n#clicktocall_button{display:none;}\r\n\r\nh1 {display:none;}\r\nh2  {display:block;color:#000;font-weight:bold;font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 16px;}\r\n#event_wrapper h1 {display:block;color:#000;font-weight:bold;font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;}\r\n#event_wrapper h2 {display:block;color:rgb(128, 128, 128);font-weight:bold;font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;}\r\n.event {border-top-color: rgb(233, 233, 233);border-top-style: solid;border-top-width: 1px;}\r\nh2.event {font-size: 13px; !important}\r\n#blog_articles h4 {color: rgb(153, 153, 153);font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 11px;font-weight:normal;}\r\n#blog_articles a {color: rgb(59, 89, 152);cursor: pointer;font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 11px;font-weight:bold;text-decoration: none;}\r\np {color: rgb(128, 128, 128);font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;}\r\na {color: rgb(59, 89, 152);cursor: pointer;font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;text-decoration: none;}\r\np a {font-weight:normal;}\r\n.comment_entry {color: rgb(128, 128, 128);font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;}\r\n#hour_grid {color: rgb(128, 128, 128);font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;}\r\n.review_wrapper {color: rgb(128, 128, 128);font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;}\r\n.review_wrapper h2  {display:block;color:#000;font-weight:bold;font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;}\r\n.review_form {color: rgb(128, 128, 128);font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;}\r\n.review_form h2  {display:block;color:#000;font-weight:bold;font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;}\r\n.review_form .spacer {display:block;margin-top:10px;}\r\n.review_wrapper h2 {clear:both;padding-top:10px;}\r\n.deal_expires_on {color: rgb(128, 128, 128);font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;}\r\n\r\n.blog_trailer {border-bottom-color: rgb(233, 233, 233);border-bottom-style: solid;border-bottom-width: 1px;}\r\n.blog_nav a {display:block;color:rgb(59, 89, 152);font-weight:bold;font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px;font-weight:normal;}\r\n.corner_top_left {display:none;}\r\n.corner_top_right {display:none;}\r\n.corner_bottom_left {display:none;}\r\n.corner_bottom_right {display:none;}\r\n.occasion_date {display:none;}\r\n\r\n.hotspot {cursor: help;padding: 0;}\r\n.hotspot_more {margin: 0; padding-bottom: 5px;}\r\n\r\n.accordion {color: rgb(128, 128, 128);font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px; !important}\r\n.accordion h2 {color: rgb(128, 128, 128);font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size: 13px; border: 1px solid #000; !important}\r\n\r\n#gift_wrapper {font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;}\r\n#gift_wrapper h2 {display:block;color:#000;font-weight:bold;font-size: 13px;border-top-color: rgb(233, 233, 233);border-top-style: solid;border-top-width: 1px;}\r\n#gift_wrapper div[id^=\'service_cat\'] { clear: left !important; }\r\n\r\n.service_row .hotspot {text-decoration:underline;font-weight:bolder;cursor:help;}\r\n.imagerow {float:left;margin:4px 10px 4px 10px;}\r\n#igc_who {clear:both;}\r\n#ref_code_in {font-size: 13px !important;}\r\n.order_grid {font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size:13px;}\r\n.service_option_grid {padding: 0 0; width: 90%; font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size:13px;}\r\n.service {margin: 4px 20px 10px 35px;}\r\n.service_row {margin: 4px 0 5px 0;padding: 0;}\r\n.service_option_radio {width: 20px; vertical-align: top; }\r\n.service_option_price {vertical-align: top;padding-left: 15px;text-align: right; }\r\n.service_category_description {margin-top: 0px;}\r\n\r\n.msg {color: #FF0000;text-align: right;font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size:13px;}\r\nform {color: rgb(128, 128, 128); font-size:13px; text-align: left;}\r\nform dt {text-align: right; margin: 1px 0;width: 30%; float: left;font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size:13px;}\r\nform dl#date dt {margin-right: 10px;}\r\nform dd {margin-left: 30%; padding-left: 5px;font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size:13px;}\r\nform dd:after {display: block; height: 0; clear: both; visibility: hidden;}\r\nform h2 {font-size:13px;}\r\n\r\n.review_text .summary {display:inline;}\r\n.review_text .summary p {display:inline;}\r\n.review_user {font-style: italic;clear:both;display:block;margin-left:45px;margin-bottom:10px;}\r\n.review_star img, .rating_star img { border: none !important; }\r\n\r\n.menu_option_grid {font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size:13px;}\r\n\r\n#grid th {font-family: \'lucida grande\',tahoma,verdana,arial,sans-serif;font-size:13px;}\r\n\r\n/*** BEGIN DEALS ***/\r\n\r\n.not_tipped { font-weight: bold; }\r\n.linked #event_wrapper #deal { margin-top: 150px; }\r\n#content #event_wrapper #deal, #boomtime_event_wrapper #event_wrapper #deal { width: 280px; }\r\n#event_wrapper #deal { margin: 30px auto; border: 2px solid #000; }\r\n#event_wrapper #deal .deal_intro h1, #event_wrapper #deal p { padding-left:5px; padding-right:5px; }\r\n#event_wrapper #deal .reverse, #event_wrapper #deal .reverse h1 { background-color: #fff; color: #333; }\r\n#event_wrapper #deal .reverse .hotspot { background-color: #fff !important; color: #333 !important; font-weight: normal !important; }\r\n#event_wrapper #deal .deal_photo { width: 100%; }\r\n#deal .deal_exclusive { padding-bottom: 3px; }\r\n#event_wrapper #deal .deal_intro { margin-top: -5px; padding-top: 5px; padding-bottom: 5px; }\r\n#event_wrapper #deal .deal_intro h1 { margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 5px; }\r\n#event_wrapper #deal p { margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 3px; }\r\n#event_wrapper #deal .deal_service, #event_wrapper #deal .deal_service .service_option_name { font-style: italic; }\r\n#event_wrapper #deal .deal_service .hotspot_content { font-style: normal; font-size: 90%; }\r\n#event_wrapper #deal .save { overflow: auto; width: 100%; text-align: center; border-bottom: 1px solid #000; padding-bottom: 2px;}\r\n#event_wrapper #deal .savings { width: 50%; float: left; }\r\n#event_wrapper #deal .savings_percent { font-size: 130%; }\r\n#event_wrapper #deal .purchased { float: right; }\r\n#content #event_wrapper #deal .purchased { padding-right: 30px; }\r\n#event_wrapper #deal .offer { padding-top: 3px; }\r\n#event_wrapper #deal .offer, #deal .to_go { text-align: center; }\r\n#event_wrapper #deal .buy_now { text-align: center; padding: 5px 0 10px 0; }\r\n#event_wrapper #deal .sold_out { text-align: center; font-size: 130%; font-weight: bold; padding: 5px 0 10px 0; }\r\n#event_wrapper #deal button { width: 125px; color: #000; cursor: pointer; text-decoration:none; border: 2px solid #000; padding: 5px 15px; font-size: 14px; border-radius:5px 5px 5px 5px; -moz-border-radius:5px 5px 5px 5px; -webkit-border-radius:5px 5px 5px 5px; background-color: #ddd; }\r\n#event_wrapper #deal button:hover { color: #000; background-color: #f9f9f9; }\r\n#event_wrapper #deal .countdown { padding: 10px 0 0 10px; background-color: #fff; color: #333; text-align: center; }\r\n#event_wrapper #deal .countdown p { margin-top: 5px; text-align: center; }\r\n#event_wrapper #countdown_dashboard { height: 45px; margin: 0px auto; width: 141px; padding-bottom: 5px; }\r\n#event_wrapper .dash  { width: 41px; height: 43px; float: left; margin-left: 2px; padding-left: 2px; padding-top: 12px; position: relative; color: #333; overflow: hidden; }\r\n#event_wrapper .hour_dash { clear: left; background: transparent url(\"https://fuse.boomtime.com/design/countdown_hour.png\") 0 0 no-repeat; }\r\n#event_wrapper .minute_dash  { background: transparent url(\"https://fuse.boomtime.com/design/countdown_minute.png\") 0 0 no-repeat; }\r\n#event_wrapper .second_dash { background: transparent url(\"https://fuse.boomtime.com/design/countdown_second.png\") 0 0 no-repeat; }\r\n#event_wrapper .dash .digit { font: bold 16pt Verdana; font-weight: bold; float: left; width: 19px; text-align: center; position: relative; }\r\n#event_wrapper #deal .share { padding: 5px; }\r\n#event_wrapper #deal .share p { text-align: center; padding: 5px 0; }\r\n#event_wrapper #deal .email_share { background: url(\"https://fuse.boomtime.com/design/email_share.png\") 0 0 no-repeat; padding: 0px 0px 6px 33px; text-align: left; }\r\n#event_wrapper #deal .deal_fb_share { padding: 10px 0; }\r\n#event_wrapper #deal .deal_fb_share iframe { width: 100% !important; }\r\n#event_wrapper #deal .terms { font-size: 80%; padding: 2px 0; }\r\n#event_wrapper #deal .powered_by { height: 20px; background-color: #d8dcd9 }\r\n#event_wrapper #deal .powered_by img { float: right; padding: 2px 2px 0 0; border-style: none; }\r\n\r\n/*** END DEALS ***/\r\n',NULL,0,0,'home',0,'',0);
#RC 11.15.13 Mantis 1366: INSERT row of data in template table

ALTER TABLE `sevence`.`org_mobile` ADD COLUMN `ios_pem_file` VARCHAR(50) NULL DEFAULT NULL  AFTER `app_access` , ADD COLUMN `android_api_key` VARCHAR(60) NULL DEFAULT NULL  AFTER `ios_pem_file` , ADD COLUMN `ios_passphrase` VARCHAR(50) NULL DEFAULT NULL  AFTER `android_api_key` ;
#RC 12.19.13 Mantis 1483: ALTER table org_mobile

CREATE  TABLE `sevence`.`push_notifications` (
  `push_notifications` INT NOT NULL AUTO_INCREMENT ,
  `org` INT(11) NOT NULL ,
  `send` DATETIME NULL ,
  `expire` DATETIME NULL ,
  `message` VARCHAR(250) NULL ,
  `link` VARCHAR(100) NULL ,
  `status` VARCHAR(10) NULL ,
  PRIMARY KEY (`push_notifications`) );
  ALTER TABLE `sevence`.`push_notifications` CHANGE COLUMN `status` `status` VARCHAR(10) NULL DEFAULT 'unsend'  ;
#RC 12.18.13 Mantis 1479: ADD new table push_notifications

  CREATE  TABLE `sevence`.`push_notifications_subscribers` (
  `push_notifications_subscribers` INT(11) NOT NULL AUTO_INCREMENT ,
  `push_notifications` INT(11) NULL ,
  `device_type` VARCHAR(25) NULL ,
  `device_id` VARCHAR(100) NULL ,
  PRIMARY KEY (`push_notifications_subscribers`) ,
  INDEX `push_notifications_idx` (`push_notifications` ASC) ,
  CONSTRAINT `push_notifications`
    FOREIGN KEY (`push_notifications` )
    REFERENCES `sevence`.`push_notifications` (`push_notifications` )
    ON DELETE NO ACTION
    ON UPDATE CASCADE);
ALTER TABLE `sevence`.`push_notifications_subscribers` CHANGE COLUMN `device_type` `device_type` INT(11) NULL  ;
#RC 12.18.13 Mantis 1479: ADD new table push_notifications_subscribers

CREATE  TABLE `sevence`.`org_mobile_subscribers` (
  `org_mobile_subscribers` INT(11) NOT NULL AUTO_INCREMENT ,
  `org` INT(11) NULL ,
  `device_type` INT(11) NOT NULL ,
  `device_id` VARCHAR(50) NULL ,
  PRIMARY KEY (`org_mobile_subscribers`))
  #RC 12.18.13 Mantis 1479: ADD new table org_mobile_subscribers

ALTER TABLE `sevence`.`org_mobile_subscribers` CHANGE COLUMN `org_mobile_subscribers` `org_mobile_subscriber` INT(11) NOT NULL AUTO_INCREMENT  , RENAME TO  `sevence`.`org_mobile_subscriber` ;
#RC 12.19.13 Mantis 1483: ALTER table org_mobile_subscribers

ALTER TABLE `sevence`.`org_mobile_subscriber` ADD COLUMN `timestamp` INT(20) NULL DEFAULT 0  AFTER `device_id` ;
#KA 01.07.14 Mantis 0001481: So we can track failed notifications and delete subscribers

ALTER TABLE `sevence`.`org_mobile_subscriber` CHANGE COLUMN `device_id` `device_id` VARCHAR(255) NULL DEFAULT NULL  ;
ALTER TABLE `sevence`.`push_notifications_subscribers` CHANGE COLUMN `device_id` `device_id` VARCHAR(255) NULL DEFAULT NULL  ;
#RD 12.27.13 update device_id varchar limit
