--
-- Host: wally-balls    Database: mydb
-- ------------------------------------------------------


--
-- Table structure for table `AX_windows`
--

CREATE TABLE `AX_windows` (
  `user_id` int(11) NOT NULL DEFAULT 0,
  `sequence_number` int(11) NOT NULL DEFAULT 0,
  `window_id` varchar(8) NOT NULL DEFAULT '',
  `config` text DEFAULT NULL,
  PRIMARY KEY (`user_id`,`sequence_number`,`window_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `admin_permissions`
--

CREATE TABLE `admin_permissions` (
  `user_id` int(11) NOT NULL DEFAULT 0,
  `description` varchar(50) NOT NULL DEFAULT '',
  `where_condition` varchar(200) NOT NULL DEFAULT '',
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `affiliate_promocode_map`
--

CREATE TABLE `affiliate_promocode_map` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tune_affiliate_id` int(10) DEFAULT NULL,
  `affiliate_name` varchar(40) DEFAULT NULL,
  `coupon_id` varchar(40) DEFAULT NULL,
  `status` enum('active','expired') NOT NULL DEFAULT 'active',
  `created_by` varchar(50) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `aggregate_revenue`
--

CREATE TABLE `aggregate_revenue` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `orderid` varchar(50) DEFAULT NULL,
  `itemname` varchar(300) DEFAULT NULL,
  `discountname` varchar(300) DEFAULT NULL,
  `payment_gross` float DEFAULT NULL,
  `payment_fee` float DEFAULT NULL,
  `ordertype` varchar(50) DEFAULT NULL,
  `paytype` varchar(50) DEFAULT NULL,
  `provider` enum('paypal','infusionsoft','chargebee','unknown') NOT NULL DEFAULT 'unknown',
  `userid` int(11) DEFAULT NULL,
  `contactid` varchar(50) DEFAULT NULL,
  `username` varchar(50) DEFAULT NULL,
  `paydate` datetime DEFAULT NULL,
  `issubscription` tinyint(1) DEFAULT NULL,
  `ispayment` tinyint(1) DEFAULT NULL,
  `pprefid` int(11) DEFAULT NULL,
  `affiliateid` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pprefid` (`pprefid`),
  KEY `userid` (`userid`),
  KEY `idx_pay_affil` (`paydate`,`affiliateid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ai_admin`
--

CREATE TABLE `ai_admin` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `strategy_id` varchar(100) NOT NULL,
  `creation` datetime DEFAULT NULL,
  `trading_date` datetime DEFAULT NULL,
  `max_trades` int(11) NOT NULL DEFAULT 3,
  `strategy_name` varchar(200) NOT NULL,
  `notes` text DEFAULT NULL,
  `category` varchar(50) DEFAULT 'main',
  PRIMARY KEY (`id`),
  UNIQUE KEY `strategy_day_id` (`strategy_id`,`trading_date`,`category`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ai_base_strategies`
--

CREATE TABLE `ai_base_strategies` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `cloud_link` char(32) DEFAULT NULL,
  `description` blob DEFAULT NULL,
  `strategy_type` enum('intraday','swing') NOT NULL DEFAULT 'intraday',
  `is_long` tinyint(4) DEFAULT 1,
  `status` enum('optimize','nooptimize','archived') NOT NULL DEFAULT 'optimize',
  `settings` blob DEFAULT NULL,
  `segment` varchar(50) DEFAULT 'main',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ai_overnight_status`
--

CREATE TABLE `ai_overnight_status` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `start_time` datetime DEFAULT NULL,
  `hostname` varchar(100) DEFAULT NULL,
  `category` varchar(200) DEFAULT 'main',
  `stage` int(11) NOT NULL DEFAULT 1,
  `percent_complete` double NOT NULL DEFAULT 0,
  `num_strategies` int(11) NOT NULL DEFAULT 0,
  `finish_time` datetime DEFAULT NULL,
  `updated` datetime DEFAULT NULL,
  `strategies_complete` int(11) DEFAULT NULL,
  `status` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `start_host_category` (`start_time`,`hostname`,`category`),
  KEY `start_time` (`start_time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ai_strategies`
--

CREATE TABLE `ai_strategies` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `strategy_id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `creation` datetime DEFAULT NULL,
  `optimize_date` datetime DEFAULT NULL,
  `trading_date` datetime DEFAULT NULL,
  `settings` blob NOT NULL,
  `cloud_link` char(32) NOT NULL,
  `is_long` tinyint(4) NOT NULL DEFAULT 1,
  `timeframe` enum('intraday','swing') NOT NULL DEFAULT 'intraday',
  `score` double NOT NULL DEFAULT 0,
  `total_trades` int(11) NOT NULL DEFAULT 0,
  `max_trades_per_day` int(11) NOT NULL DEFAULT 0,
  `is_winrate` double NOT NULL DEFAULT 0,
  `is_profit_factor` double NOT NULL DEFAULT 0,
  `oos_winrate` double NOT NULL DEFAULT 0,
  `oos_profit_factor` double NOT NULL DEFAULT 0,
  `trading_date_ymd` varchar(10) DEFAULT NULL,
  `category` varchar(50) DEFAULT 'main',
  PRIMARY KEY (`id`),
  UNIQUE KEY `strategy_id` (`strategy_id`,`trading_date`,`category`),
  KEY `trading_date_ymd` (`trading_date_ymd`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ai_trades`
--

CREATE TABLE `ai_trades` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `trade_id` varchar(100) NOT NULL,
  `symbol` varchar(20) NOT NULL,
  `creation` datetime DEFAULT NULL,
  `entry_date` datetime DEFAULT NULL,
  `exit_date` datetime DEFAULT NULL,
  `shares` int(11) NOT NULL DEFAULT 1,
  `entry_price` double NOT NULL,
  `exit_price` double DEFAULT NULL,
  `stop_price` double DEFAULT NULL,
  `target_price` double DEFAULT NULL,
  `time_stop` datetime DEFAULT NULL,
  `exit_reason` varchar(100) DEFAULT NULL,
  `profit` double NOT NULL DEFAULT 0,
  `max_profit` double NOT NULL DEFAULT 0,
  `min_profit` double NOT NULL DEFAULT 0,
  `max_profit_time` datetime DEFAULT NULL,
  `min_profit_time` datetime DEFAULT NULL,
  `is_long` tinyint(4) NOT NULL DEFAULT 1,
  `winner` tinyint(4) NOT NULL DEFAULT 0,
  `strategy_id` int(11) DEFAULT NULL,
  `nonexit_profit` double NOT NULL DEFAULT 0,
  `fullrisk_profit` double NOT NULL DEFAULT 0,
  `spy_change` double DEFAULT NULL,
  `smart_stop` double DEFAULT NULL,
  `profit_change_15` double DEFAULT NULL,
  `profit_change_5` double DEFAULT NULL,
  `change_15_timet` int(11) DEFAULT NULL,
  `change_5_timet` int(11) DEFAULT NULL,
  `profit_history` text DEFAULT NULL,
  `profit_history_nonexit` text DEFAULT NULL,
  `profit_history_fullrisk` text DEFAULT NULL,
  `distance_from_target_price` double DEFAULT NULL,
  `distance_from_stop_price` double DEFAULT NULL,
  `last_price` double DEFAULT NULL,
  `market_cap` float DEFAULT NULL,
  `entry_date_ymd` varchar(10) DEFAULT NULL,
  `update_source` varchar(100) DEFAULT NULL,
  `category` varchar(200) DEFAULT 'main',
  `include_long_term` tinyint(4) NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`),
  UNIQUE KEY `trade_id` (`trade_id`),
  KEY `entry_date_ymd` (`entry_date_ymd`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ai_trades_test`
--

CREATE TABLE `ai_trades_test` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `trade_id` varchar(100) NOT NULL,
  `symbol` varchar(20) NOT NULL,
  `creation` datetime DEFAULT NULL,
  `entry_date` datetime DEFAULT NULL,
  `exit_date` datetime DEFAULT NULL,
  `shares` int(11) NOT NULL DEFAULT 1,
  `entry_price` double NOT NULL,
  `exit_price` double DEFAULT NULL,
  `stop_price` double DEFAULT NULL,
  `target_price` double DEFAULT NULL,
  `time_stop` datetime DEFAULT NULL,
  `exit_reason` varchar(100) DEFAULT NULL,
  `profit` double NOT NULL DEFAULT 0,
  `max_profit` double NOT NULL DEFAULT 0,
  `min_profit` double NOT NULL DEFAULT 0,
  `max_profit_time` datetime DEFAULT NULL,
  `min_profit_time` datetime DEFAULT NULL,
  `is_long` tinyint(4) NOT NULL DEFAULT 1,
  `winner` tinyint(4) NOT NULL DEFAULT 0,
  `strategy_id` int(11) DEFAULT NULL,
  `nonexit_profit` double NOT NULL DEFAULT 0,
  `fullrisk_profit` double NOT NULL DEFAULT 0,
  `spy_change` double DEFAULT NULL,
  `smart_stop` double DEFAULT NULL,
  `profit_change_15` double DEFAULT NULL,
  `profit_change_5` double DEFAULT NULL,
  `change_15_timet` int(11) DEFAULT NULL,
  `change_5_timet` int(11) DEFAULT NULL,
  `profit_history` text DEFAULT NULL,
  `profit_history_nonexit` text DEFAULT NULL,
  `profit_history_fullrisk` text DEFAULT NULL,
  `distance_from_target_price` double DEFAULT NULL,
  `distance_from_stop_price` double DEFAULT NULL,
  `last_price` double DEFAULT NULL,
  `market_cap` float DEFAULT NULL,
  `entry_date_ymd` varchar(10) DEFAULT NULL,
  `update_source` varchar(100) DEFAULT NULL,
  `category` varchar(200) DEFAULT 'main',
  PRIMARY KEY (`id`),
  UNIQUE KEY `trade_id` (`trade_id`),
  KEY `entry_date_ymd` (`entry_date_ymd`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `alert_shards`
--

CREATE TABLE `alert_shards` (
  `day` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `table_name` varchar(50) DEFAULT NULL,
  `first_id` bigint(20) DEFAULT NULL,
  `last_id` bigint(20) DEFAULT NULL,
  `live` enum('Y','N','in progress') NOT NULL DEFAULT 'N',
  PRIMARY KEY (`day`),
  UNIQUE KEY `date` (`date`),
  KEY `last_id` (`last_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `alerts`
--

CREATE TABLE `alerts` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `alert_type` varchar(10) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `description` varchar(255) DEFAULT NULL,
  `timestamp` datetime DEFAULT NULL,
  `price` float DEFAULT NULL,
  `last` float DEFAULT NULL,
  `spread` float DEFAULT NULL,
  `fake` enum('Y','N') NOT NULL DEFAULT 'N',
  `bid_size` int(11) DEFAULT NULL,
  `ask_size` int(11) DEFAULT NULL,
  `relvol` float DEFAULT NULL,
  `quality` float DEFAULT NULL,
  `most_recent_close` float DEFAULT NULL,
  `expected_open` float DEFAULT NULL,
  `num` int(11) DEFAULT NULL,
  `tvol` bigint(20) DEFAULT NULL,
  `rsi_5` float DEFAULT NULL,
  `rsi_15` float DEFAULT NULL,
  `up_5` smallint(6) DEFAULT NULL,
  `up_10` smallint(6) DEFAULT NULL,
  `up_15` smallint(6) DEFAULT NULL,
  `up_30` smallint(6) DEFAULT NULL,
  `sale_condition` smallint(6) DEFAULT NULL,
  `distance_from_nbbo` float DEFAULT NULL,
  `t_high` float DEFAULT NULL,
  `t_low` float DEFAULT NULL,
  `p_up_1` float DEFAULT NULL,
  `p_up_5` float DEFAULT NULL,
  `p_up_10` float DEFAULT NULL,
  `p_up_15` float DEFAULT NULL,
  `p_up_30` float DEFAULT NULL,
  `p_up_60` float DEFAULT NULL,
  `p_up_120` float DEFAULT NULL,
  `v_up_1` int(11) DEFAULT NULL,
  `v_up_5` int(11) DEFAULT NULL,
  `v_up_10` int(11) DEFAULT NULL,
  `v_up_15` int(11) DEFAULT NULL,
  `v_up_30` int(11) DEFAULT NULL,
  `sma_2_8` float DEFAULT NULL,
  `sma_2_20` float DEFAULT NULL,
  `sma_2_200` float DEFAULT NULL,
  `sma_5_8` float DEFAULT NULL,
  `sma_5_20` float DEFAULT NULL,
  `sma_5_200` float DEFAULT NULL,
  `sma_15_8` float DEFAULT NULL,
  `sma_15_20` float DEFAULT NULL,
  `sma_15_200` float DEFAULT NULL,
  `range_30` float DEFAULT NULL,
  `range_60` float DEFAULT NULL,
  `range_120` float DEFAULT NULL,
  `qqqq_5` float DEFAULT NULL,
  `qqqq_10` float DEFAULT NULL,
  `qqqq_15` float DEFAULT NULL,
  `qqqq_30` float DEFAULT NULL,
  `qqqq_d` float DEFAULT NULL,
  `spy_5` float DEFAULT NULL,
  `spy_10` float DEFAULT NULL,
  `spy_15` float DEFAULT NULL,
  `spy_30` float DEFAULT NULL,
  `spy_d` float DEFAULT NULL,
  `dia_5` float DEFAULT NULL,
  `dia_10` float DEFAULT NULL,
  `dia_15` float DEFAULT NULL,
  `dia_30` float DEFAULT NULL,
  `dia_d` float DEFAULT NULL,
  `up_60` smallint(6) DEFAULT NULL,
  `sma_60_8` float DEFAULT NULL,
  `sma_60_20` float DEFAULT NULL,
  `sma_60_200` float DEFAULT NULL,
  `range_15` float DEFAULT NULL,
  `std_5_20` float DEFAULT NULL,
  `std_15_20` float DEFAULT NULL,
  `std_60_20` float DEFAULT NULL,
  `alt_description` varchar(255) DEFAULT NULL,
  `vwap` float DEFAULT NULL,
  `rsi_1` float DEFAULT NULL,
  `rsi_2` float DEFAULT NULL,
  `prange_5` float DEFAULT NULL,
  `prange_15` float DEFAULT NULL,
  `prange_30` float DEFAULT NULL,
  `prange_60` float DEFAULT NULL,
  `put_v` int(11) DEFAULT NULL,
  `call_v` int(11) DEFAULT NULL,
  `p_up_2` float DEFAULT NULL,
  `range_2` float DEFAULT NULL,
  `range_5` float DEFAULT NULL,
  `social_rv` float DEFAULT NULL,
  `up_1` smallint(6) DEFAULT NULL,
  `up_2` smallint(6) DEFAULT NULL,
  `bid` float DEFAULT NULL,
  `ask` float DEFAULT NULL,
  `sma_2_5` float DEFAULT NULL,
  `sma_5_5` float DEFAULT NULL,
  `sma_15_5` float DEFAULT NULL,
  `pm_volume` int(11) DEFAULT NULL,
  `rsi_60` float DEFAULT NULL,
  `sma_15_130` float DEFAULT NULL,
  `high_pre` float DEFAULT NULL,
  `low_pre` float DEFAULT NULL,
  `v_up_2` int(11) DEFAULT NULL,
  `limit_up` float DEFAULT NULL,
  `limit_down` float DEFAULT NULL,
  `sma_2_10` float DEFAULT NULL,
  `sma_5_10` float DEFAULT NULL,
  `sma_15_10` float DEFAULT NULL,
  `sma_60_10` float DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`),
  KEY `symbol` (`symbol`,`id`),
  KEY `by_type` (`alert_type`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 MAX_ROWS=4294967295 AVG_ROW_LENGTH=100 DELAY_KEY_WRITE=1;

--
-- Table structure for table `alerts_bad_id`
--

CREATE TABLE `alerts_bad_id` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `alert_type` varchar(10) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `description` varchar(255) DEFAULT NULL,
  `timestamp` datetime DEFAULT NULL,
  `price` float DEFAULT NULL,
  `last` float DEFAULT NULL,
  `spread` float DEFAULT NULL,
  `fake` enum('Y','N') NOT NULL DEFAULT 'N',
  `bid_size` int(11) DEFAULT NULL,
  `ask_size` int(11) DEFAULT NULL,
  `relvol` float DEFAULT NULL,
  `quality` float DEFAULT NULL,
  `most_recent_close` float DEFAULT NULL,
  `expected_open` float DEFAULT NULL,
  `num` int(11) DEFAULT NULL,
  `tvol` int(11) DEFAULT NULL,
  `rsi_5` float DEFAULT NULL,
  `rsi_15` float DEFAULT NULL,
  `up_5` smallint(6) DEFAULT NULL,
  `up_10` smallint(6) DEFAULT NULL,
  `up_15` smallint(6) DEFAULT NULL,
  `up_30` smallint(6) DEFAULT NULL,
  `sale_condition` smallint(6) DEFAULT NULL,
  `distance_from_nbbo` float DEFAULT NULL,
  `t_high` float DEFAULT NULL,
  `t_low` float DEFAULT NULL,
  `p_up_1` float DEFAULT NULL,
  `p_up_5` float DEFAULT NULL,
  `p_up_10` float DEFAULT NULL,
  `p_up_15` float DEFAULT NULL,
  `p_up_30` float DEFAULT NULL,
  `p_up_60` float DEFAULT NULL,
  `p_up_120` float DEFAULT NULL,
  `v_up_1` int(11) DEFAULT NULL,
  `v_up_5` int(11) DEFAULT NULL,
  `v_up_10` int(11) DEFAULT NULL,
  `v_up_15` int(11) DEFAULT NULL,
  `v_up_30` int(11) DEFAULT NULL,
  `sma_2_8` float DEFAULT NULL,
  `sma_2_20` float DEFAULT NULL,
  `sma_2_200` float DEFAULT NULL,
  `sma_5_8` float DEFAULT NULL,
  `sma_5_20` float DEFAULT NULL,
  `sma_5_200` float DEFAULT NULL,
  `sma_15_8` float DEFAULT NULL,
  `sma_15_20` float DEFAULT NULL,
  `sma_15_200` float DEFAULT NULL,
  `range_30` float DEFAULT NULL,
  `range_60` float DEFAULT NULL,
  `range_120` float DEFAULT NULL,
  `qqqq_5` float DEFAULT NULL,
  `qqqq_10` float DEFAULT NULL,
  `qqqq_15` float DEFAULT NULL,
  `qqqq_30` float DEFAULT NULL,
  `qqqq_d` float DEFAULT NULL,
  `spy_5` float DEFAULT NULL,
  `spy_10` float DEFAULT NULL,
  `spy_15` float DEFAULT NULL,
  `spy_30` float DEFAULT NULL,
  `spy_d` float DEFAULT NULL,
  `dia_5` float DEFAULT NULL,
  `dia_10` float DEFAULT NULL,
  `dia_15` float DEFAULT NULL,
  `dia_30` float DEFAULT NULL,
  `dia_d` float DEFAULT NULL,
  `up_60` smallint(6) DEFAULT NULL,
  `sma_60_8` float DEFAULT NULL,
  `sma_60_20` float DEFAULT NULL,
  `sma_60_200` float DEFAULT NULL,
  `range_15` float DEFAULT NULL,
  `std_5_20` float DEFAULT NULL,
  `std_15_20` float DEFAULT NULL,
  `std_60_20` float DEFAULT NULL,
  `alt_description` varchar(255) DEFAULT NULL,
  `vwap` float DEFAULT NULL,
  `rsi_1` float DEFAULT NULL,
  `rsi_2` float DEFAULT NULL,
  `prange_5` float DEFAULT NULL,
  `prange_15` float DEFAULT NULL,
  `prange_30` float DEFAULT NULL,
  `prange_60` float DEFAULT NULL,
  `put_v` int(11) DEFAULT NULL,
  `call_v` int(11) DEFAULT NULL,
  `p_up_2` float DEFAULT NULL,
  `range_2` float DEFAULT NULL,
  `range_5` float DEFAULT NULL,
  `social_rv` float DEFAULT NULL,
  `up_1` smallint(6) DEFAULT NULL,
  `up_2` smallint(6) DEFAULT NULL,
  `bid` float DEFAULT NULL,
  `ask` float DEFAULT NULL,
  `sma_2_5` float DEFAULT NULL,
  `sma_5_5` float DEFAULT NULL,
  `sma_15_5` float DEFAULT NULL,
  `pm_volume` int(11) DEFAULT NULL,
  `rsi_60` float DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`),
  KEY `symbol` (`symbol`,`id`),
  KEY `by_type` (`alert_type`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 MAX_ROWS=4294967295 AVG_ROW_LENGTH=100 DELAY_KEY_WRITE=1;

--
-- Table structure for table `alerts_daily`
--

CREATE TABLE `alerts_daily` (
  `d_symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `date` date NOT NULL DEFAULT '0000-00-00',
  `advol` bigint(20) DEFAULT NULL,
  `advol_5d` bigint(20) DEFAULT NULL,
  `list_exch` varchar(4) DEFAULT NULL,
  `up_days` int(11) DEFAULT NULL,
  `volatility` float DEFAULT NULL,
  `range_contraction` int(11) DEFAULT NULL,
  `sma_200` float DEFAULT NULL,
  `sma_50` float DEFAULT NULL,
  `sma_20` float DEFAULT NULL,
  `rsi_d` float DEFAULT NULL,
  `bright_volatility` float DEFAULT NULL,
  `high_p` float DEFAULT NULL,
  `low_p` float DEFAULT NULL,
  `close_p` float DEFAULT NULL,
  `open_p` float DEFAULT NULL,
  `volume_p` bigint(20) DEFAULT NULL,
  `high_52w` float DEFAULT NULL,
  `low_52w` float DEFAULT NULL,
  `std_20` float DEFAULT NULL,
  `bunny_130` float DEFAULT NULL,
  `consolidation_days` int(11) DEFAULT NULL,
  `consolidation_high` float DEFAULT NULL,
  `consolidation_low` float DEFAULT NULL,
  `average_true_range` float DEFAULT NULL,
  `last_price` float DEFAULT NULL,
  `high_life` float DEFAULT NULL,
  `low_life` float DEFAULT NULL,
  `prev_put_volume` bigint(20) DEFAULT NULL,
  `prev_call_volume` bigint(20) DEFAULT NULL,
  `avg_put_call_volume` float DEFAULT NULL,
  `debt` float DEFAULT NULL,
  `assets` float DEFAULT NULL,
  `eps` float DEFAULT NULL,
  `pe_ratio` float DEFAULT NULL,
  `revenue` float DEFAULT NULL,
  `income` float DEFAULT NULL,
  `earnings` float DEFAULT NULL,
  `market_cap` float DEFAULT NULL,
  `beta` float DEFAULT NULL,
  `shares_out` bigint(20) DEFAULT NULL,
  `yield` float DEFAULT NULL,
  `dividend` float DEFAULT NULL,
  `trailing_dividend_rate` float DEFAULT NULL,
  `forward_dividend_rate` float DEFAULT NULL,
  `high_5d` float DEFAULT NULL,
  `low_5d` float DEFAULT NULL,
  `close_5d` float DEFAULT NULL,
  `high_10d` float DEFAULT NULL,
  `low_10d` float DEFAULT NULL,
  `close_10d` float DEFAULT NULL,
  `high_20d` float DEFAULT NULL,
  `low_20d` float DEFAULT NULL,
  `close_20d` float DEFAULT NULL,
  `adx_14d` float DEFAULT NULL,
  `pdi_14d` float DEFAULT NULL,
  `mdi_14d` float DEFAULT NULL,
  `shares_per_print` float DEFAULT NULL,
  `short_interest` bigint(20) DEFAULT NULL,
  `earning_day` float DEFAULT NULL,
  `sector` varchar(200) DEFAULT NULL,
  `close_1y` float DEFAULT NULL,
  `advol_3m` float DEFAULT NULL,
  `sma_8` float DEFAULT NULL,
  `social_average` float DEFAULT NULL,
  `close_last_year` float DEFAULT NULL,
  `revenue_growth` float DEFAULT NULL,
  `earnings_growth` float DEFAULT NULL,
  `held_by_insiders` float DEFAULT NULL,
  `held_by_institutions` float DEFAULT NULL,
  `short_ratio` float DEFAULT NULL,
  `short_float` float DEFAULT NULL,
  `cash` float DEFAULT NULL,
  `enterprise_value` float DEFAULT NULL,
  `peg` float DEFAULT NULL,
  `estimated_quarterly_eps_growth` float DEFAULT NULL,
  `estimated_annual_eps_growth` float DEFAULT NULL,
  `short_growth` float DEFAULT NULL,
  `cusip` char(9) DEFAULT NULL,
  `flt` float DEFAULT NULL,
  `social_q` float DEFAULT NULL,
  `social_m` float DEFAULT NULL,
  `social_w` float DEFAULT NULL,
  `social_d` float DEFAULT NULL,
  `high_104w` float DEFAULT NULL,
  `low_104w` float DEFAULT NULL,
  `high_13w` float DEFAULT NULL,
  `low_13w` float DEFAULT NULL,
  `high_26w` float DEFAULT NULL,
  `low_26w` float DEFAULT NULL,
  `high_39w` float DEFAULT NULL,
  `low_39w` float DEFAULT NULL,
  `avwap_2_pv` float DEFAULT NULL,
  `avwap_2_tv` float DEFAULT NULL,
  `avwap_3_pv` float DEFAULT NULL,
  `avwap_3_tv` float DEFAULT NULL,
  `avwap_4_pv` float DEFAULT NULL,
  `avwap_4_tv` float DEFAULT NULL,
  `avwap_5_pv` float DEFAULT NULL,
  `avwap_5_tv` float DEFAULT NULL,
  `sma_10` float DEFAULT NULL,
  `days_to_cover` float DEFAULT NULL,
  `interest_income` float DEFAULT NULL,
  PRIMARY KEY (`date`,`d_symbol`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `alerts_keep_2`
--

CREATE TABLE `alerts_keep_2` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `alert_type` varchar(10) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `description` varchar(255) DEFAULT NULL,
  `timestamp` datetime DEFAULT NULL,
  `price` float DEFAULT NULL,
  `last` float DEFAULT NULL,
  `spread` float DEFAULT NULL,
  `fake` enum('Y','N') NOT NULL DEFAULT 'N',
  `bid_size` int(11) DEFAULT NULL,
  `ask_size` int(11) DEFAULT NULL,
  `relvol` float DEFAULT NULL,
  `quality` float DEFAULT NULL,
  `most_recent_close` float DEFAULT NULL,
  `expected_open` float DEFAULT NULL,
  `num` int(11) DEFAULT NULL,
  `tvol` int(11) DEFAULT NULL,
  `rsi_5` float DEFAULT NULL,
  `rsi_15` float DEFAULT NULL,
  `up_5` smallint(6) DEFAULT NULL,
  `up_10` smallint(6) DEFAULT NULL,
  `up_15` smallint(6) DEFAULT NULL,
  `up_30` smallint(6) DEFAULT NULL,
  `sale_condition` smallint(6) DEFAULT NULL,
  `distance_from_nbbo` float DEFAULT NULL,
  `t_high` float DEFAULT NULL,
  `t_low` float DEFAULT NULL,
  `p_up_1` float DEFAULT NULL,
  `p_up_5` float DEFAULT NULL,
  `p_up_10` float DEFAULT NULL,
  `p_up_15` float DEFAULT NULL,
  `p_up_30` float DEFAULT NULL,
  `p_up_60` float DEFAULT NULL,
  `p_up_120` float DEFAULT NULL,
  `v_up_1` int(11) DEFAULT NULL,
  `v_up_5` int(11) DEFAULT NULL,
  `v_up_10` int(11) DEFAULT NULL,
  `v_up_15` int(11) DEFAULT NULL,
  `v_up_30` int(11) DEFAULT NULL,
  `sma_2_8` float DEFAULT NULL,
  `sma_2_20` float DEFAULT NULL,
  `sma_2_200` float DEFAULT NULL,
  `sma_5_8` float DEFAULT NULL,
  `sma_5_20` float DEFAULT NULL,
  `sma_5_200` float DEFAULT NULL,
  `sma_15_8` float DEFAULT NULL,
  `sma_15_20` float DEFAULT NULL,
  `sma_15_200` float DEFAULT NULL,
  `range_30` float DEFAULT NULL,
  `range_60` float DEFAULT NULL,
  `range_120` float DEFAULT NULL,
  `qqqq_5` float DEFAULT NULL,
  `qqqq_10` float DEFAULT NULL,
  `qqqq_15` float DEFAULT NULL,
  `qqqq_30` float DEFAULT NULL,
  `qqqq_d` float DEFAULT NULL,
  `spy_5` float DEFAULT NULL,
  `spy_10` float DEFAULT NULL,
  `spy_15` float DEFAULT NULL,
  `spy_30` float DEFAULT NULL,
  `spy_d` float DEFAULT NULL,
  `dia_5` float DEFAULT NULL,
  `dia_10` float DEFAULT NULL,
  `dia_15` float DEFAULT NULL,
  `dia_30` float DEFAULT NULL,
  `dia_d` float DEFAULT NULL,
  `up_60` smallint(6) DEFAULT NULL,
  `sma_60_8` float DEFAULT NULL,
  `sma_60_20` float DEFAULT NULL,
  `sma_60_200` float DEFAULT NULL,
  `range_15` float DEFAULT NULL,
  `std_5_20` float DEFAULT NULL,
  `std_15_20` float DEFAULT NULL,
  `std_60_20` float DEFAULT NULL,
  `alt_description` varchar(255) DEFAULT NULL,
  `vwap` float DEFAULT NULL,
  `rsi_1` float DEFAULT NULL,
  `rsi_2` float DEFAULT NULL,
  `prange_5` float DEFAULT NULL,
  `prange_15` float DEFAULT NULL,
  `prange_30` float DEFAULT NULL,
  `prange_60` float DEFAULT NULL,
  `put_v` int(11) DEFAULT NULL,
  `call_v` int(11) DEFAULT NULL,
  `p_up_2` float DEFAULT NULL,
  `range_2` float DEFAULT NULL,
  `range_5` float DEFAULT NULL,
  `social_rv` float DEFAULT NULL,
  `up_1` smallint(6) DEFAULT NULL,
  `up_2` smallint(6) DEFAULT NULL,
  `bid` float DEFAULT NULL,
  `ask` float DEFAULT NULL,
  `sma_2_5` float DEFAULT NULL,
  `sma_5_5` float DEFAULT NULL,
  `sma_15_5` float DEFAULT NULL,
  `pm_volume` int(11) DEFAULT NULL,
  `rsi_60` float DEFAULT NULL,
  `sma_15_130` float DEFAULT NULL,
  `high_pre` float DEFAULT NULL,
  `low_pre` float DEFAULT NULL,
  `v_up_2` int(11) DEFAULT NULL,
  `limit_up` float DEFAULT NULL,
  `limit_down` float DEFAULT NULL,
  `sma_2_10` float DEFAULT NULL,
  `sma_5_10` float DEFAULT NULL,
  `sma_15_10` float DEFAULT NULL,
  `sma_60_10` float DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`),
  KEY `symbol` (`symbol`,`id`),
  KEY `by_type` (`alert_type`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 MAX_ROWS=4294967295 AVG_ROW_LENGTH=100 DELAY_KEY_WRITE=1;

--
-- Table structure for table `auto_wl`
--

CREATE TABLE `auto_wl` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `wl_include` varchar(50) NOT NULL DEFAULT '',
  `username_pattern` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `wl_include` (`wl_include`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `backoffice_access_log`
--

CREATE TABLE `backoffice_access_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `timestamp` datetime DEFAULT NULL,
  `username` varchar(50) DEFAULT NULL,
  `access_type` enum('accessed','denied') DEFAULT NULL,
  `page_accessed` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `backoffice_group_members`
--

CREATE TABLE `backoffice_group_members` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `group_id` int(11) NOT NULL,
  `group_member` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `backoffice_permission_groups`
--

CREATE TABLE `backoffice_permission_groups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `group_name` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `banned_emails`
--

CREATE TABLE `banned_emails` (
  `pattern` varchar(60) NOT NULL DEFAULT '',
  `notes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `banned_ips`
--

CREATE TABLE `banned_ips` (
  `ip` varchar(15) NOT NULL DEFAULT '',
  `notes` text DEFAULT NULL,
  PRIMARY KEY (`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `brightback_coupon_activity`
--

CREATE TABLE `brightback_coupon_activity` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `chargebee_subscription_id` varchar(20) DEFAULT NULL,
  `email` varchar(40) DEFAULT NULL,
  `coupon_id` varchar(40) DEFAULT NULL,
  `date_applied` varchar(10) DEFAULT NULL,
  `expiration` varchar(10) DEFAULT NULL,
  `creation` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `subscription_pause` datetime DEFAULT NULL,
  `subscription_resume` datetime DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `class` varchar(10) DEFAULT NULL,
  `status` enum('queued','done') NOT NULL DEFAULT 'queued',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `brightback_coupon_eligibility`
--

CREATE TABLE `brightback_coupon_eligibility` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `chargebee_subscription_id` varchar(20) DEFAULT NULL,
  `coupon_id` varchar(40) DEFAULT NULL,
  `coupon_abbrv` varchar(8) DEFAULT NULL,
  `eligible_on` datetime DEFAULT NULL,
  `status` enum('queued','done') NOT NULL DEFAULT 'queued',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `brightback_coupon_list`
--

CREATE TABLE `brightback_coupon_list` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `coupon_id` varchar(40) DEFAULT NULL,
  `coupon_abbrv` varchar(8) DEFAULT NULL,
  `ineligible_period_days` int(11) DEFAULT NULL,
  `type` enum('monthly','annual') NOT NULL DEFAULT 'monthly',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `brightback_pending_requests`
--

CREATE TABLE `brightback_pending_requests` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `chargebee_subscription_id` varchar(20) DEFAULT NULL,
  `email` varchar(40) DEFAULT NULL,
  `class` varchar(10) DEFAULT NULL,
  `status` enum('queued','done') NOT NULL DEFAULT 'queued',
  `creation` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `broker_promotions`
--

CREATE TABLE `broker_promotions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime NOT NULL,
  `user_id` int(11) NOT NULL,
  `broker` varchar(100) NOT NULL,
  `stage` int(11) NOT NULL,
  `updated` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `campaignmonitor_stats`
--

CREATE TABLE `campaignmonitor_stats` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `list_name` varchar(50) NOT NULL,
  `created` datetime DEFAULT NULL,
  `TotalActiveSubscribers` int(11) NOT NULL,
  `NewActiveSubscribersToday` int(11) NOT NULL,
  `NewActiveSubscribersYesterday` int(11) NOT NULL,
  `NewActiveSubscribersThisWeek` int(11) NOT NULL,
  `NewActiveSubscribersThisMonth` int(11) NOT NULL,
  `NewActiveSubscribersThisYear` int(11) NOT NULL,
  `TotalUnsubscribes` int(11) NOT NULL,
  `UnsubscribesToday` int(11) NOT NULL,
  `UnsubscribesYesterday` int(11) NOT NULL,
  `UnsubscribesThisWeek` int(11) NOT NULL,
  `UnsubscribesThisMonth` int(11) NOT NULL,
  `UnsubscribesThisYear` int(11) NOT NULL,
  `TotalDeleted` int(11) NOT NULL,
  `DeletedToday` int(11) NOT NULL,
  `DeletedYesterday` int(11) NOT NULL,
  `DeletedThisWeek` int(11) NOT NULL,
  `DeletedThisMonth` int(11) NOT NULL,
  `DeletedThisYear` int(11) NOT NULL,
  `TotalBounces` int(11) NOT NULL,
  `BouncesToday` int(11) NOT NULL,
  `BouncesYesterday` int(11) NOT NULL,
  `BouncesThisWeek` int(11) NOT NULL,
  `BouncesThisMonth` int(11) NOT NULL,
  `BouncesThisYear` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `candles_5m`
--

CREATE TABLE `candles_5m` (
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `end_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `last_price` float DEFAULT NULL,
  `high` float DEFAULT NULL,
  `low` float DEFAULT NULL,
  PRIMARY KEY (`symbol`,`end_time`),
  KEY `end_time` (`end_time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `candles_d`
--

CREATE TABLE `candles_d` (
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `date` date NOT NULL DEFAULT '0000-00-00',
  `open` float DEFAULT NULL,
  `close` float DEFAULT NULL,
  PRIMARY KEY (`symbol`,`date`),
  KEY `date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `client_use_case`
--

CREATE TABLE `client_use_case` (
  `date` date NOT NULL,
  `user_id` int(11) NOT NULL,
  `description` varchar(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
  `count` int(11) NOT NULL,
  PRIMARY KEY (`date`,`description`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `cloud_layout`
--

CREATE TABLE `cloud_layout` (
  `strategy_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `share_code` char(32) NOT NULL DEFAULT '',
  `icon` varchar(50) DEFAULT '',
  `clear_previous_layout` enum('Y','N') NOT NULL DEFAULT 'N',
  `fill_screen` enum('Y','N') NOT NULL DEFAULT 'N',
  `short_description` blob NOT NULL,
  `long_description` blob NOT NULL,
  `creation` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `window_count` int(11) NOT NULL DEFAULT 0,
  `original_size` int(11) NOT NULL,
  `layout` varchar(1) NOT NULL,
  PRIMARY KEY (`strategy_id`),
  UNIQUE KEY `share_code` (`share_code`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `company_profile`
--

CREATE TABLE `company_profile` (
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `summary` text DEFAULT NULL,
  `country` varchar(60) DEFAULT NULL,
  `website` varchar(80) DEFAULT NULL,
  `protected` tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`symbol`,`protected`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `currently_on_archive`
--

CREATE TABLE `currently_on_archive` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime DEFAULT NULL,
  `timestamp` datetime DEFAULT NULL,
  `category` enum('class','vendor_id','trader_type','white_label') NOT NULL,
  `time_period` enum('now','day','week','month','quarter') NOT NULL,
  `label` varchar(200) DEFAULT NULL,
  `login_count` int(11) DEFAULT NULL,
  `batch_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `batch_id` (`batch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `default_layout`
--

CREATE TABLE `default_layout` (
  `white_label` varchar(50) NOT NULL,
  `share_code` char(32) NOT NULL,
  PRIMARY KEY (`white_label`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `delete_me_cloud_layout`
--

CREATE TABLE `delete_me_cloud_layout` (
  `strategy_id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `share_code` char(32) NOT NULL DEFAULT '',
  `layout` blob NOT NULL,
  `icon` varchar(50) DEFAULT '',
  `clear_previous_layout` enum('Y','N') NOT NULL DEFAULT 'N',
  `fill_screen` enum('Y','N') NOT NULL DEFAULT 'N',
  `short_description` blob NOT NULL,
  `long_description` blob NOT NULL,
  `creation` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `window_count` int(11) NOT NULL DEFAULT 0,
  `original_size` int(11) NOT NULL,
  PRIMARY KEY (`strategy_id`),
  UNIQUE KEY `share_code` (`share_code`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `demo_user`
--

CREATE TABLE `demo_user` (
  `first` datetime NOT NULL,
  `last` datetime NOT NULL,
  `count` int(11) NOT NULL DEFAULT 1,
  `email` varbinary(50) NOT NULL,
  `first_name` varbinary(50) NOT NULL DEFAULT '',
  `last_name` varbinary(50) NOT NULL DEFAULT '',
  `source` varbinary(10) NOT NULL DEFAULT '',
  `vendor_id` varbinary(30) NOT NULL DEFAULT '',
  UNIQUE KEY `email` (`email`,`source`,`vendor_id`),
  KEY `first` (`first`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `email_demos`
--

CREATE TABLE `email_demos` (
  `email` varchar(50) NOT NULL DEFAULT '',
  `id` int(11) DEFAULT NULL,
  `start` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `email_sms_log`
--

CREATE TABLE `email_sms_log` (
  `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `user_id` int(11) NOT NULL DEFAULT 0,
  `sent_to` varchar(50) NOT NULL DEFAULT '',
  KEY `timestamp` (`timestamp`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `email_sms_strategies`
--

CREATE TABLE `email_sms_strategies` (
  `user_id` int(11) NOT NULL,
  `strategy_id` tinyint(3) unsigned NOT NULL,
  `recent_count` tinyint(4) NOT NULL,
  `last` datetime NOT NULL,
  `settings` blob NOT NULL,
  `title` tinyblob NOT NULL,
  `body` tinyblob NOT NULL,
  `enabled` enum('Y','N') NOT NULL DEFAULT 'N',
  PRIMARY KEY (`user_id`,`strategy_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `esignal_monthly`
--

CREATE TABLE `esignal_monthly` (
  `month` char(7) NOT NULL,
  `user_id` int(11) NOT NULL,
  `state` enum('paid','trial','expired') NOT NULL,
  PRIMARY KEY (`month`,`state`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `esignal_trial_override`
--

CREATE TABLE `esignal_trial_override` (
  `user_id` int(11) NOT NULL,
  `date` datetime NOT NULL,
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `esignal_user`
--

CREATE TABLE `esignal_user` (
  `first` datetime NOT NULL,
  `last` datetime NOT NULL,
  `count` int(11) NOT NULL DEFAULT 1,
  `user_id` int(11) NOT NULL,
  `state` enum('paid','trial','expired') NOT NULL,
  PRIMARY KEY (`user_id`,`state`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `etrade_bill`
--

CREATE TABLE `etrade_bill` (
  `start` date NOT NULL,
  `recorded` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `user_count` int(11) NOT NULL,
  `final` enum('Y','N') NOT NULL DEFAULT 'N',
  PRIMARY KEY (`start`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `execution_messages`
--

CREATE TABLE `execution_messages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `ti_user_id` int(11) NOT NULL DEFAULT 0,
  `remote_user_name` varchar(32) NOT NULL DEFAULT '',
  `action` enum('cancel','market_order','limit_order','stop_order','time_stop','stop_limit','log_in','order_filled','exec','account','other') NOT NULL,
  `shares` int(10) unsigned NOT NULL DEFAULT 0,
  `direction` enum('buy_long','buy_to_cover','sell_short','sell_long','n_a') NOT NULL DEFAULT 'n_a',
  `source` varchar(32) NOT NULL DEFAULT '',
  `vendor_id` varchar(50) NOT NULL DEFAULT '',
  `symbol` varchar(30) DEFAULT NULL,
  `exec_id` varchar(200) DEFAULT NULL,
  `live` tinyint(4) DEFAULT NULL,
  `broker` varchar(20) DEFAULT NULL,
  `fill_price` double DEFAULT NULL,
  `is_long` tinyint(4) DEFAULT NULL,
  `trade_id` varchar(100) DEFAULT NULL,
  `stop_price` double DEFAULT NULL,
  `limit_price` double DEFAULT NULL,
  `good_after_time` datetime DEFAULT NULL,
  `order_id` varchar(200) DEFAULT NULL,
  `status` varchar(200) DEFAULT NULL,
  `broker_id` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`),
  KEY `ti_user_id` (`ti_user_id`),
  KEY `idx_action` (`action`),
  KEY `idx_broker` (`broker`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `external_linking_history`
--

CREATE TABLE `external_linking_history` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `timestamp` datetime NOT NULL,
  `source` varchar(50) NOT NULL,
  `symbol` varchar(20) NOT NULL,
  `user_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `failure_data`
--

CREATE TABLE `failure_data` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `server_name` varchar(55) DEFAULT NULL,
  `jira_id` varchar(10) DEFAULT NULL,
  `failure_history` text DEFAULT NULL,
  `status` enum('open','close') NOT NULL DEFAULT 'open',
  `last_time` datetime DEFAULT NULL,
  `last_seen` datetime DEFAULT NULL,
  `when_closed` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `feed_config`
--

CREATE TABLE `feed_config` (
  `feed_id` int(11) NOT NULL DEFAULT 0,
  `category_id` int(11) NOT NULL DEFAULT 0,
  `settings` blob NOT NULL,
  `last_update` datetime DEFAULT NULL,
  PRIMARY KEY (`feed_id`,`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `feed_users`
--


--
-- Table structure for table `format_lists`
--

CREATE TABLE `format_lists` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL DEFAULT '',
  `description` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `format_values`
--

CREATE TABLE `format_values` (
  `list_id` int(11) NOT NULL DEFAULT 0,
  `alert_type` varchar(10) NOT NULL DEFAULT '',
  `cell_desc` text NOT NULL,
  `pre_desc` text NOT NULL,
  `post_desc` text NOT NULL,
  `font_color` text DEFAULT NULL,
  `font_bold` tinyint(1) NOT NULL DEFAULT 0,
  `bg_color` varchar(7) NOT NULL DEFAULT '',
  `bg_texture` text DEFAULT NULL,
  PRIMARY KEY (`list_id`,`alert_type`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `free_preview`
--


--
-- Table structure for table `global_settings_files`
--

CREATE TABLE `global_settings_files` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `halts`
--

CREATE TABLE `halts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `symbol` varchar(10) NOT NULL,
  `created` datetime NOT NULL,
  `start` datetime NOT NULL,
  `end` datetime DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `reason` varchar(100) DEFAULT NULL,
  `resume_alert` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `symbol` (`symbol`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `hidden_settings`
--

CREATE TABLE `hidden_settings` (
  `wl_include` varchar(50) NOT NULL DEFAULT '',
  `name` varchar(25) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `settings` blob NOT NULL,
  UNIQUE KEY `wl_include` (`wl_include`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `holidays`
--

CREATE TABLE `holidays` (
  `day` date NOT NULL,
  `closed` set('US','Canada','London') NOT NULL DEFAULT '',
  `half_day` set('US','Canada','London') NOT NULL DEFAULT '',
  `notes` blob NOT NULL,
  PRIMARY KEY (`day`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `hosts`
--

CREATE TABLE `hosts` (
  `host_name` varchar(20) NOT NULL DEFAULT '',
  `IP` varchar(20) NOT NULL DEFAULT '',
  `last_update` datetime DEFAULT NULL,
  PRIMARY KEY (`host_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ib_integration_processed`
--

CREATE TABLE `ib_integration_processed` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ib_record_id` int(10) DEFAULT NULL,
  `ib_email` varchar(40) DEFAULT NULL,
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ift_changes`
--

CREATE TABLE `ift_changes` (
  `timestamp` datetime NOT NULL,
  `action` enum('start','stop') NOT NULL,
  `username` varchar(37) NOT NULL,
  `email` varchar(50) DEFAULT NULL,
  `real_name` varchar(50) DEFAULT NULL,
  KEY `timestamp` (`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ift_current`
--

CREATE TABLE `ift_current` (
  `username` varchar(37) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `email` varchar(50) DEFAULT NULL,
  `real_name` varchar(50) DEFAULT NULL,
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ift_previous`
--

CREATE TABLE `ift_previous` (
  `username` varchar(37) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `email` varchar(50) DEFAULT NULL,
  `real_name` varchar(50) DEFAULT NULL,
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `iit_user_transactions`
--

CREATE TABLE `iit_user_transactions` (
  `user_id` int(11) NOT NULL,
  `enabled` datetime NOT NULL,
  `disabled` datetime NOT NULL DEFAULT '9999-12-31 23:59:59',
  PRIMARY KEY (`user_id`,`enabled`),
  KEY `enabled` (`enabled`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `infusion_order_items`
--

CREATE TABLE `infusion_order_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT NULL,
  `name` varchar(50) DEFAULT NULL,
  `ordertype` varchar(50) DEFAULT NULL,
  `units` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `infusion_payments`
--

CREATE TABLE `infusion_payments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT NULL,
  `orderid` int(11) DEFAULT NULL,
  `orderitemid` int(11) DEFAULT NULL,
  `orderitemcount` int(11) DEFAULT NULL,
  `orderitemtotal` int(11) DEFAULT NULL,
  `itemname` varchar(50) DEFAULT NULL,
  `ordertype` varchar(50) DEFAULT NULL,
  `units` int(11) DEFAULT NULL,
  `status` enum('complete','error','queued','partiallycomplete') NOT NULL DEFAULT 'queued',
  `userid` int(11) DEFAULT NULL,
  `contactid` int(11) DEFAULT NULL,
  `username` varchar(50) DEFAULT NULL,
  `paydate` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `infusionsoft_affiliates`
--


--
-- Table structure for table `infusionsoft_commissions`
--

CREATE TABLE `infusionsoft_commissions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `contactlastname` varchar(100) DEFAULT NULL,
  `contactfirstname` varchar(100) DEFAULT NULL,
  `description` varchar(300) DEFAULT NULL,
  `productname` varchar(300) DEFAULT NULL,
  `amtearned` float DEFAULT NULL,
  `invoiceid` int(11) DEFAULT NULL,
  `contactid` int(11) DEFAULT NULL,
  `saleaffid` int(11) DEFAULT NULL,
  `affiliate_id` int(11) DEFAULT NULL,
  `soldbylastname` varchar(100) DEFAULT NULL,
  `soldbyfirstname` varchar(100) DEFAULT NULL,
  `dateearned` datetime DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`),
  UNIQUE KEY `commission_id` (`productname`,`invoiceid`,`contactid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `infusionsoft_contacts`
--

CREATE TABLE `infusionsoft_contacts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `contactid` int(11) NOT NULL,
  `city` varchar(300) DEFAULT NULL,
  `city2` varchar(300) DEFAULT NULL,
  `company` varchar(300) DEFAULT NULL,
  `country` varchar(300) DEFAULT NULL,
  `country2` varchar(300) DEFAULT NULL,
  `contactnotes` varchar(300) DEFAULT NULL,
  `createdby` int(11) DEFAULT NULL,
  `datecreated` datetime DEFAULT '0000-00-00 00:00:00',
  `email` varchar(300) DEFAULT NULL,
  `email2` varchar(300) DEFAULT NULL,
  `firstname` varchar(300) DEFAULT NULL,
  `groups` varchar(300) DEFAULT NULL,
  `lastname` varchar(300) DEFAULT NULL,
  `lastupdated` datetime DEFAULT '0000-00-00 00:00:00',
  `lastupdatedby` int(11) NOT NULL,
  `leadsourceid` int(11) NOT NULL,
  `leadsource` varchar(300) DEFAULT NULL,
  `middlename` varchar(300) DEFAULT NULL,
  `phone1` varchar(300) DEFAULT NULL,
  `postalcode` varchar(300) DEFAULT NULL,
  `referralcode` varchar(300) DEFAULT NULL,
  `state` varchar(300) DEFAULT NULL,
  `streetaddress1` varchar(300) DEFAULT NULL,
  `username` varchar(300) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
  `validated` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `contactid` (`contactid`),
  KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `infusionsoft_countries`
--

CREATE TABLE `infusionsoft_countries` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `country_code` varchar(2) NOT NULL DEFAULT '',
  `country_name` varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `infusionsoft_groups`
--

CREATE TABLE `infusionsoft_groups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `groupid` int(11) NOT NULL,
  `name` varchar(300) DEFAULT NULL,
  `categoryid` int(11) NOT NULL,
  `description` varchar(300) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `groupid` (`groupid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `infusionsoft_invoice`
--

CREATE TABLE `infusionsoft_invoice` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `affiliateid` int(11) NOT NULL,
  `contactid` int(11) NOT NULL,
  `creditstatus` int(11) NOT NULL,
  `datecreated` datetime DEFAULT '0000-00-00 00:00:00',
  `description` varchar(300) DEFAULT NULL,
  `invoiceid` int(11) NOT NULL,
  `invoicetotal` float DEFAULT NULL,
  `invoicetype` varchar(300) DEFAULT NULL,
  `jobid` int(11) NOT NULL,
  `lastupdated` datetime DEFAULT '0000-00-00 00:00:00',
  `leadaffiliateid` int(11) DEFAULT NULL,
  `payplanstatus` int(11) DEFAULT NULL,
  `paystatus` int(11) DEFAULT NULL,
  `productsold` varchar(300) DEFAULT NULL,
  `promocode` varchar(300) DEFAULT NULL,
  `refundstatus` int(11) DEFAULT NULL,
  `synced` int(11) DEFAULT NULL,
  `totaldue` float DEFAULT NULL,
  `totalpaid` float DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `invoiceid` (`invoiceid`),
  KEY `contact_id` (`contactid`),
  KEY `affililate_id` (`affiliateid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `infusionsoft_payment`
--

CREATE TABLE `infusionsoft_payment` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `chargeid` int(11) NOT NULL,
  `commission` int(11) NOT NULL,
  `contactid` int(11) NOT NULL,
  `paymentid` int(11) NOT NULL,
  `invoiceid` int(11) NOT NULL,
  `lastupdated` datetime DEFAULT '0000-00-00 00:00:00',
  `payamt` float DEFAULT NULL,
  `paydate` datetime DEFAULT '0000-00-00 00:00:00',
  `paynote` varchar(300) DEFAULT NULL,
  `paytype` varchar(300) DEFAULT NULL,
  `refundid` int(11) NOT NULL,
  `synced` int(11) DEFAULT NULL,
  `userid` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `paymentid` (`paymentid`),
  KEY `invoice_id` (`invoiceid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `infusionsoft_products`
--

CREATE TABLE `infusionsoft_products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `productid` int(11) NOT NULL,
  `name` varchar(300) DEFAULT NULL,
  `productprice` float NOT NULL,
  `needsdigitaldelivery` tinyint(4) DEFAULT NULL,
  `shortdescription` varchar(300) DEFAULT NULL,
  `status` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `productid` (`productid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `infusionsoft_recurring_orders`
--

CREATE TABLE `infusionsoft_recurring_orders` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `affiliateid` int(11) NOT NULL,
  `autocharge` tinyint(4) NOT NULL,
  `billingamount` float DEFAULT NULL,
  `billingcycle` int(11) NOT NULL,
  `contactid` int(11) NOT NULL,
  `enddate` datetime DEFAULT '0000-00-00 00:00:00',
  `frequency` int(11) NOT NULL,
  `recurring_order_id` int(11) NOT NULL,
  `lastbilldate` datetime DEFAULT '0000-00-00 00:00:00',
  `leadaffiliateid` int(11) NOT NULL,
  `maxretry` int(11) NOT NULL,
  `merchantaccountid` int(11) NOT NULL,
  `nextbilldate` datetime DEFAULT '0000-00-00 00:00:00',
  `numdaysbetweenretry` int(11) NOT NULL,
  `originatingorderid` int(11) NOT NULL,
  `paidthrudate` datetime DEFAULT '0000-00-00 00:00:00',
  `productid` int(11) NOT NULL,
  `promocode` varchar(200) DEFAULT NULL,
  `qty` int(11) NOT NULL,
  `reasonstopped` varchar(300) DEFAULT NULL,
  `shippingoptionid` int(11) NOT NULL,
  `startdate` datetime DEFAULT '0000-00-00 00:00:00',
  `status` varchar(200) NOT NULL,
  `subscriptionplanid` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `recurring_order_id` (`recurring_order_id`),
  KEY `affiliate_id` (`affiliateid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `infusionsoft_referrals`
--

CREATE TABLE `infusionsoft_referrals` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `referralid` int(11) NOT NULL,
  `affiliateid` int(11) NOT NULL,
  `contactid` int(11) NOT NULL,
  `dateexpires` datetime DEFAULT '0000-00-00 00:00:00',
  `dateset` datetime DEFAULT '0000-00-00 00:00:00',
  `ipaddress` varchar(300) DEFAULT NULL,
  `info` varchar(300) DEFAULT NULL,
  `source` varchar(300) DEFAULT NULL,
  `reftype` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `referralid` (`referralid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `infusionsoft_subscriptionplans`
--

CREATE TABLE `infusionsoft_subscriptionplans` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `active` tinyint(4) DEFAULT NULL,
  `cycle` int(11) NOT NULL,
  `frequency` int(11) NOT NULL,
  `planid` int(11) NOT NULL,
  `planprice` float NOT NULL,
  `productid` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `planid` (`planid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `initial_emails`
--

CREATE TABLE `initial_emails` (
  `email` varchar(50) NOT NULL DEFAULT '',
  `user_id` int(11) NOT NULL DEFAULT 0,
  `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `insiders`
--

CREATE TABLE `insiders` (
  `id` int(11) NOT NULL,
  `date` date NOT NULL DEFAULT '0000-00-00',
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `filer_name` varchar(30) DEFAULT NULL,
  `relationship_type` int(11) DEFAULT NULL,
  `relationship` varchar(30) DEFAULT NULL,
  `transaction_type` int(11) DEFAULT NULL,
  `ownership_type` int(11) DEFAULT NULL,
  `form_type` int(11) DEFAULT NULL,
  `price_to` float DEFAULT NULL,
  `price_from` float DEFAULT NULL,
  `shares` int(11) DEFAULT NULL,
  `total_shares_owned` int(11) DEFAULT NULL,
  `transaction` varchar(30) DEFAULT NULL,
  `ownership` varchar(30) DEFAULT NULL,
  `form` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `symbol` (`symbol`),
  KEY `date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `iphone_notify_queue`
--


--
-- Table structure for table `iphone_track`
--

CREATE TABLE `iphone_track` (
  `created` datetime NOT NULL,
  `request` blob NOT NULL,
  `api_user_id` int(10) unsigned NOT NULL,
  `hardware_id` varchar(50) NOT NULL,
  `initial_ip` varchar(16) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `leaddyno_grandfathering`
--

CREATE TABLE `leaddyno_grandfathering` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tune_affiliate_id` int(10) DEFAULT NULL,
  `lead_email` varchar(40) DEFAULT NULL,
  `affiliate_email` varchar(40) DEFAULT NULL,
  `type` enum('migrated','admin') NOT NULL DEFAULT 'migrated',
  `created_by` varchar(50) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `status` enum('active','expired') NOT NULL DEFAULT 'active',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `limit_alerts`
--

CREATE TABLE `limit_alerts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `local_id` varchar(100) NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  `status` enum('WORKING','EXPIRED','INVALIDATED','TRIGGERED','DELETED') NOT NULL DEFAULT 'WORKING',
  `user_id` varchar(100) NOT NULL,
  `symbol` varchar(20) NOT NULL,
  `price` double NOT NULL,
  `invalid_price` double DEFAULT NULL,
  `expires` datetime DEFAULT NULL,
  `triggered` datetime DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `is_long` tinyint(4) NOT NULL DEFAULT 1,
  `after_hours` tinyint(4) NOT NULL DEFAULT 1,
  `long_after` tinyint(4) NOT NULL DEFAULT 1,
  PRIMARY KEY (`id`),
  UNIQUE KEY `local_id` (`local_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `link_destination`
--

CREATE TABLE `link_destination` (
  `user_id` int(11) NOT NULL DEFAULT 0,
  `link_type` varchar(20) NOT NULL DEFAULT '',
  `arg1` varchar(255) DEFAULT NULL,
  `arg2` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `list_permissions`
--

CREATE TABLE `list_permissions` (
  `user_id` int(11) NOT NULL DEFAULT 0,
  `owner_id` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`owner_id`,`user_id`),
  UNIQUE KEY `user_id` (`user_id`,`owner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `manual_subscription`
--

CREATE TABLE `manual_subscription` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `first_month` varchar(10) NOT NULL DEFAULT '',
  `each_month` varchar(10) NOT NULL DEFAULT '',
  `oddsmaker` enum('Y','N') NOT NULL DEFAULT 'N',
  `valid_until` date NOT NULL DEFAULT '0000-00-00',
  `subscr_id` varchar(127) NOT NULL DEFAULT '',
  `notes` blob NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `market_explorer_permissions`
--

CREATE TABLE `market_explorer_permissions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `window_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `timestamp` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `window_id` (`window_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `market_explorer_usage`
--

CREATE TABLE `market_explorer_usage` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `window_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `timestamp` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `window_id` (`window_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `market_explorer_windows`
--

CREATE TABLE `market_explorer_windows` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  `prototype` text DEFAULT NULL,
  `layout` text DEFAULT NULL,
  `enabled` tinyint(4) NOT NULL DEFAULT 1,
  `development_mode` tinyint(4) NOT NULL DEFAULT 1,
  `created_by` varchar(50) DEFAULT NULL,
  `updated_by` varchar(50) DEFAULT NULL,
  `access_type` enum('all','premium','list','not_list') NOT NULL DEFAULT 'all',
  `access_list` text DEFAULT NULL,
  `symbols` text DEFAULT NULL,
  `listener_count` int(11) NOT NULL DEFAULT 0,
  `max_listener_count` int(11) NOT NULL DEFAULT 0,
  `max_listener_date` datetime DEFAULT NULL,
  `category` varchar(100) DEFAULT NULL,
  `timeframe` varchar(5) DEFAULT NULL,
  `row_count` int(11) DEFAULT NULL,
  `symbol_count` int(11) DEFAULT NULL,
  `last_update_time` int(11) DEFAULT NULL,
  `total_row_count` int(11) DEFAULT NULL,
  `last_grid_update` datetime DEFAULT NULL,
  `current_result_rows` int(11) DEFAULT NULL,
  `server` varchar(100) DEFAULT NULL,
  `lookback_type` varchar(50) DEFAULT NULL,
  `lookback_bars` int(11) DEFAULT NULL,
  `filter_column` varchar(200) DEFAULT NULL,
  `sort_by` varchar(200) DEFAULT NULL,
  `rows_processed` int(11) DEFAULT NULL,
  `processing_time` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `messages_to_user`
--

CREATE TABLE `messages_to_user` (
  `user_id` int(11) NOT NULL,
  `status` enum('new','unread','read','deleted') NOT NULL DEFAULT 'new',
  `creation` datetime NOT NULL,
  `body` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Table structure for table `mobile_settings`
--


--
-- Table structure for table `monitor_alive`
--

CREATE TABLE `monitor_alive` (
  `name` varchar(50) NOT NULL DEFAULT '',
  `schedule` enum('master','slave','alert_server','new_alert_server','24x7','24x7_NxCore','overnight','unknown') NOT NULL DEFAULT 'unknown',
  `last_update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `disabled` enum('Y','N') NOT NULL DEFAULT 'Y',
  `warning_seconds` int(11) NOT NULL DEFAULT 0,
  `notification_type` enum('sevone','default','ai','backup','tiq_server','notification_only') NOT NULL DEFAULT 'default',
  `category` varchar(50) NOT NULL DEFAULT 'default',
  `environment` varchar(50) NOT NULL DEFAULT 'default',
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `naics_lookup`
--

CREATE TABLE `naics_lookup` (
  `code` varchar(6) NOT NULL,
  `sector` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `nasdaq_location`
--

CREATE TABLE `nasdaq_location` (
  `date` date NOT NULL DEFAULT '0000-00-00',
  `user_id` int(11) NOT NULL DEFAULT 0,
  `location` varchar(255) NOT NULL DEFAULT '',
  UNIQUE KEY `date` (`date`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `nasdaq_user`
--

CREATE TABLE `nasdaq_user` (
  `date` date NOT NULL DEFAULT '0000-00-00',
  `user_id` int(11) NOT NULL DEFAULT 0,
  `status` enum('pro','non-pro','non-pro-us','undeclared','immune') NOT NULL DEFAULT 'pro',
  UNIQUE KEY `date` (`date`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `not_moved`
--

CREATE TABLE `not_moved` (
  `id` int(11) DEFAULT NULL,
  `old` varchar(37) DEFAULT NULL,
  `new` varchar(37) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `not_moved_old`
--

CREATE TABLE `not_moved_old` (
  `id` int(11) DEFAULT NULL,
  `old` varchar(37) DEFAULT NULL,
  `new` varchar(37) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `notification_batches`
--

CREATE TABLE `notification_batches` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime NOT NULL,
  `entered_by` varchar(100) NOT NULL,
  `subject` varchar(250) NOT NULL,
  `target_type` enum('all','standard','premium','list') DEFAULT 'list',
  `target_list` text DEFAULT NULL,
  `msg_type` enum('info','notification','outage') DEFAULT 'info',
  `msg_text` text DEFAULT NULL,
  `requires_acknowledgement` tinyint(4) DEFAULT 0,
  `url` text DEFAULT NULL,
  `start_date` datetime DEFAULT NULL,
  `end_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `notifications`
--

CREATE TABLE `notifications` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime NOT NULL,
  `user_id` int(11) NOT NULL,
  `subject` varchar(250) NOT NULL,
  `batch_id` int(11) NOT NULL,
  `status` enum('unread','read','deleted') DEFAULT 'unread',
  `msg_type` enum('info','notification','outage') DEFAULT 'info',
  `msg_text` text DEFAULT NULL,
  `start_date` datetime DEFAULT NULL,
  `end_date` datetime DEFAULT NULL,
  `read_date` datetime DEFAULT NULL,
  `deleted_date` datetime DEFAULT NULL,
  `acknowledged_date` datetime DEFAULT NULL,
  `requires_acknowledgement` tinyint(4) DEFAULT 0,
  `url` text DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ns_alerts`
--

CREATE TABLE `ns_alerts` (
  `alert_id` bigint(20) NOT NULL,
  `strategy_id` int(11) NOT NULL,
  `date` date NOT NULL DEFAULT '0000-00-00',
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `ns_response` blob DEFAULT NULL,
  `payload` blob DEFAULT NULL,
  `response_code` int(11) DEFAULT NULL,
  `ftp_success` tinyint(1) DEFAULT 0,
  PRIMARY KEY (`date`,`symbol`),
  KEY `alert_id` (`alert_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `ns_strategies`
--

CREATE TABLE `ns_strategies` (
  `strategy_id` int(11) NOT NULL AUTO_INCREMENT,
  `settings` blob NOT NULL,
  `last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`strategy_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `nyse_user`
--

CREATE TABLE `nyse_user` (
  `date` date NOT NULL DEFAULT '0000-00-00',
  `user_id` int(11) NOT NULL DEFAULT 0,
  `status` enum('pro','non-pro','non-pro-us','undeclared','immune') NOT NULL DEFAULT 'pro',
  UNIQUE KEY `date` (`date`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `oauth`
--


--
-- Table structure for table `oauth_tokens`
--


--
-- Table structure for table `oddsmaker_use`
--

CREATE TABLE `oddsmaker_use` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `user_id` int(11) NOT NULL DEFAULT 0,
  `settings` text DEFAULT NULL,
  `direction` enum('up','down') DEFAULT NULL,
  `exit_condition` text DEFAULT NULL,
  `end_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`),
  KEY `user_id` (`user_id`,`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `one_time_payments`
--

CREATE TABLE `one_time_payments` (
  `txn_id` varchar(25) NOT NULL DEFAULT '',
  `msg_id` int(11) DEFAULT NULL,
  `timestamp` datetime DEFAULT NULL,
  PRIMARY KEY (`txn_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `other_payments`
--

CREATE TABLE `other_payments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `wl_include` varchar(50) DEFAULT NULL,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `expires_before` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `expires_after` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `price` double NOT NULL DEFAULT 0,
  `ip` varchar(15) NOT NULL DEFAULT '',
  `more_info` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`),
  KEY `wl_include` (`wl_include`,`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `password_reset`
--


--
-- Table structure for table `payment_refunds`
--

CREATE TABLE `payment_refunds` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) DEFAULT NULL,
  `customer_id` varchar(25) DEFAULT NULL,
  `refund_id` varchar(15) DEFAULT NULL,
  `refund_date` datetime DEFAULT '0000-00-00 00:00:00',
  `payment_provider` enum('chargebee','other') NOT NULL DEFAULT 'other',
  `customer_email` varchar(50) DEFAULT NULL,
  `amount_allocated` double DEFAULT NULL,
  `amount_refunded` double DEFAULT NULL,
  `status` enum('queued','complete','none') NOT NULL DEFAULT 'none',
  `affiliate_email` varchar(50) DEFAULT NULL,
  `referral_provider` enum('leaddyno','other') NOT NULL DEFAULT 'other',
  `payment_id` varchar(15) DEFAULT NULL,
  `ld_link_purchase_id` int(15) DEFAULT NULL,
  `admin_notes` text DEFAULT NULL,
  `created` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `clawback` double DEFAULT NULL,
  `purchase_date` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `performance_monitor_data`
--

CREATE TABLE `performance_monitor_data` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `version` varchar(200) NOT NULL,
  `created` datetime NOT NULL,
  `status` enum('green','yellow','red','unknown') DEFAULT NULL,
  `charts` int(11) DEFAULT NULL,
  `alerts` int(11) DEFAULT NULL,
  `alert_grids` int(11) DEFAULT NULL,
  `alert_rows` int(11) DEFAULT NULL,
  `price_alerts` int(11) DEFAULT NULL,
  `price_alert_grids` int(11) DEFAULT NULL,
  `price_alert_rows` int(11) DEFAULT NULL,
  `top_lists` int(11) DEFAULT NULL,
  `top_list_grids` int(11) DEFAULT NULL,
  `top_list_rows` int(11) DEFAULT NULL,
  `brokerage_plus` int(11) DEFAULT NULL,
  `brokerage_plus_grids` int(11) DEFAULT NULL,
  `brokerage_plus_rows` int(11) DEFAULT NULL,
  `ssws` int(11) DEFAULT NULL,
  `ssw_grids` int(11) DEFAULT NULL,
  `ssw_rows` int(11) DEFAULT NULL,
  `symbol_links` int(11) DEFAULT NULL,
  `pinned_windows` int(11) DEFAULT NULL,
  `minimized_windows` int(11) DEFAULT NULL,
  `dock_panel_windows` int(11) DEFAULT NULL,
  `docked_windows` int(11) DEFAULT NULL,
  `total_cpu_usage` double DEFAULT NULL,
  `app_cpu_usage` double DEFAULT NULL,
  `total_memory_usage` double DEFAULT NULL,
  `app_memory_usage` double DEFAULT NULL,
  `time_running_minutes` int(11) DEFAULT NULL,
  `gdi_handles` int(11) DEFAULT NULL,
  `exceeded_field` varchar(50) DEFAULT NULL,
  `exceeded_threshold` double DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `provider_commissions`
--

CREATE TABLE `provider_commissions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime DEFAULT '0000-00-00 00:00:00',
  `provider` enum('leaddyno','other') NOT NULL DEFAULT 'other',
  `provider_affiliate_id` int(11) DEFAULT NULL,
  `amtearned` float DEFAULT NULL,
  `commissionid` int(11) DEFAULT NULL,
  `affiliate_email` varchar(50) DEFAULT NULL,
  `payer_email` varchar(50) DEFAULT NULL,
  `dateearned` datetime DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `raw_2co_field`
--

CREATE TABLE `raw_2co_field` (
  `msg_id` int(11) NOT NULL DEFAULT 0,
  `number` int(11) NOT NULL DEFAULT 0,
  `name` varchar(30) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `value` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  PRIMARY KEY (`msg_id`,`name`),
  KEY `by_field_value` (`name`,`value`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `raw_2co_msg`
--

CREATE TABLE `raw_2co_msg` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `from_ip` varchar(17) NOT NULL DEFAULT '',
  `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `success` enum('Y','N') NOT NULL DEFAULT 'N',
  `error_msg` varchar(255) DEFAULT NULL,
  `from_script` varchar(127) NOT NULL DEFAULT '',
  `devel` enum('Y','N') DEFAULT 'N',
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `raw_ipn_field`
--

CREATE TABLE `raw_ipn_field` (
  `msg_id` int(11) NOT NULL DEFAULT 0,
  `number` int(11) NOT NULL DEFAULT 0,
  `name` varchar(30) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `value` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  PRIMARY KEY (`msg_id`,`name`),
  KEY `by_field_value` (`name`,`value`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `raw_ipn_msg`
--

CREATE TABLE `raw_ipn_msg` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `from_ip` varchar(17) NOT NULL DEFAULT '',
  `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `success` enum('Y','N') NOT NULL DEFAULT 'N',
  `error_msg` varchar(255) DEFAULT NULL,
  `from_script` varchar(127) NOT NULL DEFAULT '',
  `devel` enum('Y','N') DEFAULT 'N',
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `redirect`
--

CREATE TABLE `redirect` (
  `type` enum('channel_bar','welcome_screen','channel_bar_docked') NOT NULL,
  `white_label` varchar(50) NOT NULL,
  `url` text NOT NULL,
  PRIMARY KEY (`type`,`white_label`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `restricted_filters`
--

CREATE TABLE `restricted_filters` (
  `filter_group` int(11) NOT NULL,
  `order_by` int(11) NOT NULL,
  `internal_code` varchar(7) NOT NULL,
  `sql_code` text NOT NULL,
  `description` varchar(70) NOT NULL,
  `units` varchar(30) NOT NULL,
  `flip` varchar(10) NOT NULL,
  `format` varchar(10) NOT NULL DEFAULT 'p',
  `top_list` enum('Y','N') NOT NULL DEFAULT 'Y',
  `graphics` varchar(10) NOT NULL DEFAULT '',
  `always_show` enum('Y','N') NOT NULL DEFAULT 'N',
  `keywords` varchar(100) NOT NULL DEFAULT '',
  PRIMARY KEY (`filter_group`,`order_by`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `scottrade_translate`
--

CREATE TABLE `scottrade_translate` (
  `old_id` int(11) NOT NULL,
  `old_name` varchar(30) NOT NULL,
  `new_id` int(11) NOT NULL,
  `new_name` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sharing`
--

CREATE TABLE `sharing` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `created` datetime NOT NULL,
  `share_code` char(32) NOT NULL DEFAULT '',
  `image_size` int(11) NOT NULL,
  `image_height` int(11) DEFAULT NULL,
  `image_width` int(11) DEFAULT NULL,
  `s3_url` text DEFAULT NULL,
  `s3_url_twitter` text DEFAULT NULL,
  `title` varchar(200) DEFAULT NULL,
  `pageviews` int(11) NOT NULL DEFAULT 0,
  `last_view` datetime DEFAULT NULL,
  `symbol` varchar(10) DEFAULT NULL,
  `source` varchar(30) NOT NULL DEFAULT 'chart',
  `click_source` varchar(30) DEFAULT NULL,
  `click_source_config` text DEFAULT NULL,
  `timeframe` varchar(5) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `share_code` (`share_code`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `sharing_stockraces`
--

CREATE TABLE `sharing_stockraces` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `created` datetime NOT NULL,
  `share_code` char(32) NOT NULL DEFAULT '',
  `image_size` int(11) NOT NULL,
  `image_height` int(11) DEFAULT NULL,
  `image_width` int(11) DEFAULT NULL,
  `s3_url` text DEFAULT NULL,
  `s3_url_twitter` text DEFAULT NULL,
  `title` varchar(200) DEFAULT NULL,
  `pageviews` int(11) NOT NULL DEFAULT 0,
  `last_view` datetime DEFAULT NULL,
  `source` varchar(30) NOT NULL DEFAULT 'race',
  `click_source` varchar(30) DEFAULT NULL,
  `click_source_config` text DEFAULT NULL,
  `cloud_code` char(32) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `share_code` (`share_code`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `signup_sessions`
--


--
-- Table structure for table `signup_special`
--

CREATE TABLE `signup_special` (
  `wl` varchar(50) NOT NULL DEFAULT '',
  `type` enum('fixed_date','extra_time') NOT NULL DEFAULT 'fixed_date',
  `value` varchar(50) NOT NULL DEFAULT '',
  `html_description` text NOT NULL,
  PRIMARY KEY (`wl`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `special_login`
--


--
-- Table structure for table `sponsor_authorize`
--

CREATE TABLE `sponsor_authorize` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `sponsor` varchar(50) NOT NULL DEFAULT '',
  `notes` varchar(255) NOT NULL DEFAULT '',
  `error_message` varchar(255) NOT NULL DEFAULT '',
  `timestamp` datetime DEFAULT NULL,
  `orig_email` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `sponsor` (`sponsor`,`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `stock_race_usage`
--

CREATE TABLE `stock_race_usage` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `user_id` int(11) NOT NULL DEFAULT 0,
  `toplistconfig` text DEFAULT NULL,
  `goal` text DEFAULT NULL,
  `race_lanes` int(11) NOT NULL DEFAULT 0,
  `finish_value` double NOT NULL DEFAULT 0,
  `based_on` text DEFAULT NULL,
  `sort_on` text DEFAULT NULL,
  `replace_cars` tinyint(1) DEFAULT NULL,
  `biggest_loser_wins` tinyint(1) DEFAULT NULL,
  `auto_rerun` tinyint(1) DEFAULT NULL,
  `auto_start_on_load` tinyint(1) DEFAULT NULL,
  `auto_start_at_time` tinyint(1) DEFAULT NULL,
  `auto_start_time` datetime DEFAULT NULL,
  `replay_mode` tinyint(1) DEFAULT NULL,
  `replay_from_time` datetime DEFAULT NULL,
  `replay_to_time` datetime DEFAULT NULL,
  `end_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`),
  KEY `user_id` (`user_id`,`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `stock_screener_recent`
--

CREATE TABLE `stock_screener_recent` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `start_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `settings` blob NOT NULL,
  `settings_md5` varchar(32) NOT NULL DEFAULT '',
  `ip` varchar(20) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  UNIQUE KEY `settings_md5` (`settings_md5`),
  UNIQUE KEY `ip` (`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `stocktwits_minutes`
--

CREATE TABLE `stocktwits_minutes` (
  `symbol` varchar(10) NOT NULL,
  `start` datetime NOT NULL,
  `count` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `sentiment` enum('bullish','bearish','neutral') NOT NULL DEFAULT 'neutral',
  PRIMARY KEY (`start`,`symbol`,`sentiment`,`user_id`),
  KEY `symbol` (`symbol`,`start`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `strategies`
--

CREATE TABLE `strategies` (
  `list_name` varchar(30) NOT NULL DEFAULT '',
  `id` int(11) NOT NULL DEFAULT 0,
  `name` varchar(90) NOT NULL DEFAULT '',
  `settings` blob DEFAULT NULL,
  `html_help` blob DEFAULT NULL,
  `text_help` blob DEFAULT NULL,
  `short_help` blob DEFAULT NULL,
  `icon` char(3) DEFAULT NULL,
  `user_must_modify` enum('Y','N') NOT NULL DEFAULT 'N',
  `sub_list` varchar(30) DEFAULT NULL,
  UNIQUE KEY `list_name` (`list_name`,`id`),
  KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `strategies_tl`
--

CREATE TABLE `strategies_tl` (
  `list_name` varchar(30) NOT NULL DEFAULT '',
  `id` int(11) NOT NULL DEFAULT 0,
  `name` varchar(60) NOT NULL DEFAULT '',
  `settings` blob DEFAULT NULL,
  `html_help` blob DEFAULT NULL,
  `text_help` blob DEFAULT NULL,
  `short_help` blob DEFAULT NULL,
  `icon` char(3) DEFAULT NULL,
  `user_must_modify` enum('Y','N') NOT NULL DEFAULT 'N',
  `sub_list` varchar(30) DEFAULT NULL,
  UNIQUE KEY `list_name` (`list_name`,`id`),
  KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `subscriber_history`
--

CREATE TABLE `subscriber_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `created` datetime DEFAULT NULL,
  `timestamp` datetime DEFAULT NULL,
  `category` enum('all','standard','premium') NOT NULL,
  `user_count` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `subscription_promocodes`
--

CREATE TABLE `subscription_promocodes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `promo_code` varchar(25) DEFAULT NULL,
  `percent` varchar(1) NOT NULL DEFAULT 'y',
  `dollar` varchar(1) NOT NULL DEFAULT 'n',
  `free_trial` varchar(1) NOT NULL DEFAULT 'n',
  `amount` double(7,2) DEFAULT NULL,
  `monthly_upgrade` varchar(1) NOT NULL DEFAULT 'y',
  `annual_upgrade` varchar(1) NOT NULL DEFAULT 'y',
  `has_expiry` varchar(1) NOT NULL DEFAULT 'y',
  `start_date` datetime DEFAULT '0000-00-00 00:00:00',
  `end_date` datetime DEFAULT '0000-00-00 00:00:00',
  `notes` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `support_uploads`
--

CREATE TABLE `support_uploads` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `timestamp` datetime NOT NULL,
  `user_id` int(11) NOT NULL,
  `file_name` varchar(200) NOT NULL,
  `file_size` int(11) NOT NULL,
  `save` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `symbol_info_f`
--

CREATE TABLE `symbol_info_f` (
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `company_name` varchar(300) DEFAULT NULL,
  `exchange` varchar(4) DEFAULT NULL,
  `protected` enum('Y','N') NOT NULL DEFAULT 'N',
  `naics` varchar(6) DEFAULT NULL,
  `profile` varchar(7500) DEFAULT NULL,
  PRIMARY KEY (`symbol`,`protected`),
  KEY `naics` (`naics`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `symbol_info_m`
--

CREATE TABLE `symbol_info_m` (
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `company_name_m` varchar(50) DEFAULT NULL,
  `exchange_m` varchar(4) DEFAULT NULL,
  `web_site` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`symbol`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `symbol_info_t`
--

CREATE TABLE `symbol_info_t` (
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `volatility` double DEFAULT NULL,
  `ad_vol` int(11) DEFAULT NULL,
  `sma_200` double DEFAULT NULL,
  `sma_50` double DEFAULT NULL,
  `sma_20` double DEFAULT NULL,
  `last_price` double DEFAULT NULL,
  `up_days` double DEFAULT NULL,
  `correlation_symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
  `correlation_m` double DEFAULT NULL,
  `correlation_r2` double DEFAULT NULL,
  `f_correlation_m` double DEFAULT NULL,
  `f_correlation_r2` double DEFAULT NULL,
  `range_contraction` int(11) DEFAULT NULL,
  `bunny_130` double DEFAULT NULL,
  `consolidation_days` int(11) DEFAULT NULL,
  `std_20` float DEFAULT NULL,
  `average_true_range` float DEFAULT NULL,
  `last_update` datetime DEFAULT NULL,
  PRIMARY KEY (`symbol`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `symbol_likes`
--

CREATE TABLE `symbol_likes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `added` datetime NOT NULL,
  `removed` datetime NOT NULL,
  `liked` tinyint(4) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `symbol` (`symbol`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `symbol_lists`
--

CREATE TABLE `symbol_lists` (
  `name` varchar(400) DEFAULT NULL,
  `user_id` int(11) NOT NULL DEFAULT 0,
  `id` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`user_id`,`id`),
  KEY `user_id` (`user_id`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `symbols_in_lists`
--

CREATE TABLE `symbols_in_lists` (
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `list_id` int(11) NOT NULL DEFAULT 0,
  `user_id` int(11) NOT NULL DEFAULT 0,
  UNIQUE KEY `user_id` (`user_id`,`list_id`,`symbol`),
  UNIQUE KEY `symbol` (`symbol`,`user_id`,`list_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tikiller_notes`
--

CREATE TABLE `tikiller_notes` (
  `name` varchar(30) NOT NULL,
  `value` varchar(100) NOT NULL,
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tiq_column_dependencies`
--

CREATE TABLE `tiq_column_dependencies` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `column_id` int(11) NOT NULL,
  `depends_on` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tiq_columns`
--

CREATE TABLE `tiq_columns` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `reference_name` varchar(200) NOT NULL DEFAULT '',
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  `formula` text DEFAULT NULL,
  `chartable` tinyint(4) NOT NULL DEFAULT 1,
  `requires_own_pane` tinyint(4) NOT NULL DEFAULT 1,
  `numeric_parameters` int(11) NOT NULL DEFAULT 0,
  `format` varchar(50) DEFAULT NULL,
  `size_hint` varchar(200) DEFAULT NULL,
  `category` varchar(200) DEFAULT NULL,
  `order_id` int(11) DEFAULT NULL,
  `one_color` int(11) DEFAULT NULL,
  `up_color` int(11) DEFAULT NULL,
  `down_color` int(11) DEFAULT NULL,
  `top_color` int(11) DEFAULT NULL,
  `bottom_color` int(11) DEFAULT NULL,
  `top_value` double DEFAULT NULL,
  `bottom_value` double DEFAULT NULL,
  `color_type` enum('One','UpDown','Gradient') NOT NULL DEFAULT 'One',
  `column_type` enum('Line','Bar','Arrow','Diamond','Bump','Background','StatusOnly') NOT NULL DEFAULT 'Line',
  `abbreviated_name` varchar(200) NOT NULL DEFAULT '',
  `parent_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tiq_notes`
--

CREATE TABLE `tiq_notes` (
  `user` varchar(20) NOT NULL,
  `field_name` varchar(20) NOT NULL,
  `value` double NOT NULL,
  PRIMARY KEY (`user`,`field_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tiq_parameters`
--

CREATE TABLE `tiq_parameters` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `reference_id` varchar(200) NOT NULL,
  `created` datetime NOT NULL,
  `updated` datetime NOT NULL,
  `parameter_type` enum('integer','double') NOT NULL DEFAULT 'double',
  `default_value` double NOT NULL DEFAULT 0,
  `minimum` double NOT NULL DEFAULT 0,
  `maximum` double NOT NULL DEFAULT 0,
  `description` text DEFAULT NULL,
  `format` int(11) DEFAULT 2,
  `order_id` int(11) DEFAULT 0,
  `column_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`,`column_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tiq_use`
--

CREATE TABLE `tiq_use` (
  `username` varchar(40) NOT NULL,
  `date` date NOT NULL,
  PRIMARY KEY (`date`,`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tiq_user_info`
--

CREATE TABLE `tiq_user_info` (
  `col` varchar(30) NOT NULL,
  `row` varchar(30) NOT NULL,
  `value` varchar(255) NOT NULL,
  PRIMARY KEY (`row`,`col`),
  KEY `by_value` (`col`,`value`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `top_level_strategies`
--

CREATE TABLE `top_level_strategies` (
  `external_name` varchar(90) NOT NULL DEFAULT '',
  `source` enum('client_request','white_label') NOT NULL DEFAULT 'client_request',
  `list_name` varchar(30) NOT NULL DEFAULT '',
  PRIMARY KEY (`source`,`external_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `top_level_strategies_tl`
--

CREATE TABLE `top_level_strategies_tl` (
  `external_name` varchar(90) NOT NULL DEFAULT '',
  `source` enum('client_request','white_label') NOT NULL DEFAULT 'client_request',
  `list_name` varchar(30) NOT NULL DEFAULT '',
  PRIMARY KEY (`source`,`external_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `top_list`
--

CREATE TABLE `top_list` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `symbol` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `timestamp` datetime DEFAULT NULL,
  `price` float DEFAULT NULL,
  `last` float DEFAULT NULL,
  `spread` float DEFAULT NULL,
  `bid_size` int(11) DEFAULT NULL,
  `ask_size` int(11) DEFAULT NULL,
  `relvol` float DEFAULT NULL,
  `most_recent_close` float DEFAULT NULL,
  `expected_open` float DEFAULT NULL,
  `tvol` bigint(20) DEFAULT NULL,
  `rsi_5` float DEFAULT NULL,
  `rsi_15` float DEFAULT NULL,
  `up_5` smallint(6) DEFAULT NULL,
  `up_10` smallint(6) DEFAULT NULL,
  `up_15` smallint(6) DEFAULT NULL,
  `up_30` smallint(6) DEFAULT NULL,
  `up_60` smallint(6) DEFAULT NULL,
  `sale_condition` varchar(10) DEFAULT NULL,
  `distance_from_nbbo` float DEFAULT NULL,
  `t_high` float DEFAULT NULL,
  `t_low` float DEFAULT NULL,
  `p_up_1` float DEFAULT NULL,
  `p_up_5` float DEFAULT NULL,
  `p_up_10` float DEFAULT NULL,
  `p_up_15` float DEFAULT NULL,
  `p_up_30` float DEFAULT NULL,
  `p_up_60` float DEFAULT NULL,
  `p_up_120` float DEFAULT NULL,
  `v_up_1` int(11) DEFAULT NULL,
  `v_up_5` int(11) DEFAULT NULL,
  `v_up_10` int(11) DEFAULT NULL,
  `v_up_15` int(11) DEFAULT NULL,
  `v_up_30` int(11) DEFAULT NULL,
  `sma_2_8` float DEFAULT NULL,
  `sma_2_20` float DEFAULT NULL,
  `sma_2_200` float DEFAULT NULL,
  `sma_5_8` float DEFAULT NULL,
  `sma_5_20` float DEFAULT NULL,
  `sma_5_200` float DEFAULT NULL,
  `sma_15_8` float DEFAULT NULL,
  `sma_15_20` float DEFAULT NULL,
  `sma_15_200` float DEFAULT NULL,
  `sma_60_8` float DEFAULT NULL,
  `sma_60_20` float DEFAULT NULL,
  `sma_60_200` float DEFAULT NULL,
  `range_15` float DEFAULT NULL,
  `range_30` float DEFAULT NULL,
  `range_60` float DEFAULT NULL,
  `range_120` float DEFAULT NULL,
  `qqqq_5` float DEFAULT NULL,
  `qqqq_10` float DEFAULT NULL,
  `qqqq_15` float DEFAULT NULL,
  `qqqq_30` float DEFAULT NULL,
  `qqqq_d` float DEFAULT NULL,
  `spy_5` float DEFAULT NULL,
  `spy_10` float DEFAULT NULL,
  `spy_15` float DEFAULT NULL,
  `spy_30` float DEFAULT NULL,
  `spy_d` float DEFAULT NULL,
  `dia_5` float DEFAULT NULL,
  `dia_10` float DEFAULT NULL,
  `dia_15` float DEFAULT NULL,
  `dia_30` float DEFAULT NULL,
  `dia_d` float DEFAULT NULL,
  `std_5_20` float DEFAULT NULL,
  `std_15_20` float DEFAULT NULL,
  `std_60_20` float DEFAULT NULL,
  `vwap` float DEFAULT NULL,
  `rsi_1` float DEFAULT NULL,
  `rsi_2` float DEFAULT NULL,
  `prange_5` float DEFAULT NULL,
  `prange_15` float DEFAULT NULL,
  `prange_30` float DEFAULT NULL,
  `prange_60` float DEFAULT NULL,
  `put_v` int(11) DEFAULT NULL,
  `call_v` int(11) DEFAULT NULL,
  `p_up_2` float DEFAULT NULL,
  `range_2` float DEFAULT NULL,
  `range_5` float DEFAULT NULL,
  `social_rv` double DEFAULT NULL,
  `up_1` smallint(6) DEFAULT NULL,
  `up_2` smallint(6) DEFAULT NULL,
  `bid` float DEFAULT NULL,
  `ask` float DEFAULT NULL,
  `sma_2_5` float DEFAULT NULL,
  `sma_5_5` float DEFAULT NULL,
  `sma_15_5` float DEFAULT NULL,
  `pm_volume` int(11) DEFAULT NULL,
  `rsi_60` float DEFAULT NULL,
  `sma_15_130` float DEFAULT NULL,
  `high_pre` float DEFAULT NULL,
  `low_pre` float DEFAULT NULL,
  `v_up_2` int(11) DEFAULT NULL,
  `limit_up` float DEFAULT NULL,
  `limit_down` float DEFAULT NULL,
  `sma_2_10` float DEFAULT NULL,
  `sma_5_10` float DEFAULT NULL,
  `sma_15_10` float DEFAULT NULL,
  `sma_60_10` float DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `symbol` (`symbol`),
  KEY `timestamp` (`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `trading_room_participants`
--


--
-- Table structure for table `tune_affiliate_name_id`
--

CREATE TABLE `tune_affiliate_name_id` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `affiliate_id` int(5) NOT NULL,
  `affiliate_name` varchar(60) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_affil` (`affiliate_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tune_affiliate_performance`
--

CREATE TABLE `tune_affiliate_performance` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `tune_affiliate_id` int(10) DEFAULT NULL,
  `isnew` tinyint(1) DEFAULT NULL,
  `payment_date` datetime DEFAULT NULL,
  `payment_amount` float DEFAULT NULL,
  `affiliate_commission` float DEFAULT NULL,
  `subscription_name` varchar(55) DEFAULT NULL,
  `event_id` varchar(42) DEFAULT NULL,
  `created` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `tune_affiliate_name` varchar(40) DEFAULT NULL,
  `is_internal_affiliate` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tune_id_storage`
--

CREATE TABLE `tune_id_storage` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `creation` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `customer_hash` char(65) DEFAULT NULL,
  `transaction_id` varchar(32) DEFAULT NULL,
  `offer_id` int(4) DEFAULT NULL,
  `affiliate_id` int(5) DEFAULT NULL,
  `lead_username` varchar(37) DEFAULT NULL,
  `lead_subscription_status` enum('cancelled','active') DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `tune_refund_reconciliation`
--

CREATE TABLE `tune_refund_reconciliation` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `credit_note_id` varchar(15) DEFAULT NULL,
  `note_issue_date` datetime DEFAULT '0000-00-00 00:00:00',
  `customer_id` varchar(25) DEFAULT NULL,
  `customer_name` varchar(50) DEFAULT NULL,
  `subscription_id` varchar(25) DEFAULT NULL,
  `orig_amount_paid` double DEFAULT NULL,
  `amount_refunded` double DEFAULT NULL,
  `affiliate_id` int(10) DEFAULT NULL,
  `tune_event_id` varchar(40) DEFAULT NULL,
  `status` enum('queued','complete','none') NOT NULL DEFAULT 'none',
  `admin_notes` text DEFAULT NULL,
  `created` datetime DEFAULT '0000-00-00 00:00:00',
  `updated` datetime DEFAULT '0000-00-00 00:00:00',
  `purchase_date` datetime DEFAULT NULL,
  `affiliate_name` varchar(40) DEFAULT NULL,
  `conversion_status` enum('approved','rejected','pending') DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `united_states`
--

CREATE TABLE `united_states` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `abbreviation` varchar(2) NOT NULL DEFAULT '',
  `full_name` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `user_channels`
--

CREATE TABLE `user_channels` (
  `user_id` int(11) NOT NULL,
  `channel_id` char(36) NOT NULL,
  `cloud_link` char(32) NOT NULL,
  `channel_name` varchar(255) NOT NULL,
  `image_file` blob NOT NULL,
  `mod_date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  UNIQUE KEY `user_id` (`user_id`,`channel_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_cookie`
--


--
-- Table structure for table `user_deltas`
--

CREATE TABLE `user_deltas` (
  `user_id` int(11) NOT NULL DEFAULT 0,
  `change_id` int(11) NOT NULL AUTO_INCREMENT,
  `field_name` varchar(20) NOT NULL DEFAULT '',
  `ip` varchar(16) NOT NULL DEFAULT '',
  `old_value` varchar(100) NOT NULL DEFAULT '',
  `new_value` varchar(100) NOT NULL DEFAULT '',
  `time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `notes` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`change_id`),
  UNIQUE KEY `user_id` (`user_id`,`change_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_filters`
--

CREATE TABLE `user_filters` (
  `user_id` int(11) NOT NULL,
  `internal_code` varchar(7) NOT NULL,
  `source` text NOT NULL,
  `sql_code` text NOT NULL,
  `description` varchar(70) NOT NULL,
  `units` varchar(30) NOT NULL,
  `top_list` enum('Y','N') NOT NULL DEFAULT 'Y',
  `format` varchar(10) NOT NULL DEFAULT 'p',
  `graphics` varchar(10) NOT NULL DEFAULT '',
  PRIMARY KEY (`user_id`,`internal_code`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `user_strategies`
--

CREATE TABLE `user_strategies` (
  `user_id` int(11) NOT NULL DEFAULT 0,
  `strategy_id` int(11) NOT NULL DEFAULT 0,
  `settings` blob NOT NULL,
  `description` blob NOT NULL,
  PRIMARY KEY (`user_id`,`strategy_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `users`
--


--
-- Table structure for table `valid_paypal_subscriptions`
--

CREATE TABLE `valid_paypal_subscriptions` (
  `subscr_id` varchar(127) NOT NULL DEFAULT '',
  `service_type` enum('basic') NOT NULL DEFAULT 'basic',
  `username` varchar(127) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  PRIMARY KEY (`subscr_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `valid_recurring_payment`
--

CREATE TABLE `valid_recurring_payment` (
  `recurring_id` varchar(20) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `user_id` int(11) NOT NULL,
  PRIMARY KEY (`recurring_id`,`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `view_mru`
--

CREATE TABLE `view_mru` (
  `user_id` int(11) NOT NULL DEFAULT 0,
  `start_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `settings` blob NOT NULL,
  `settings_md5` varchar(32) NOT NULL DEFAULT '',
  PRIMARY KEY (`user_id`,`settings_md5`),
  KEY `by_timestamp` (`user_id`,`start_time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `view_mru_tl`
--

CREATE TABLE `view_mru_tl` (
  `user_id` int(11) NOT NULL DEFAULT 0,
  `start_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `settings` blob NOT NULL,
  `settings_md5` varchar(32) NOT NULL DEFAULT '',
  PRIMARY KEY (`user_id`,`settings_md5`),
  KEY `by_timestamp` (`user_id`,`start_time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `weston_exclude`
--

CREATE TABLE `weston_exclude` (
  `s` varchar(20) NOT NULL DEFAULT '',
  PRIMARY KEY (`s`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `weston_exclude_bollinger`
--

CREATE TABLE `weston_exclude_bollinger` (
  `s` varchar(20) NOT NULL DEFAULT '',
  PRIMARY KEY (`s`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Table structure for table `youtube_index`
--

CREATE TABLE `youtube_index` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `link` text DEFAULT NULL,
  `title` text DEFAULT NULL,
  `transcript` text DEFAULT NULL,
  `live` enum('Y','N') NOT NULL DEFAULT 'N',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping routines for database 'mydb'
--
DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `extract`(whole varchar(255),field_name varchar(255)) RETURNS varchar(255) CHARSET latin1
    NO SQL
    DETERMINISTIC
begin
  declare location int;
  set whole = concat("&", whole, "&");
  set field_name = concat("&", field_name, "=");
  set location = locate(field_name, whole);
  if location < 1 then return null;
  end if;
  set whole = substring(whole, location + length(field_name));
  set location = locate("&", whole);
  set whole = left(whole, location - 1);
  return whole;
end ;;
DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `otcfix`()
wholeblock:BEGIN
declare x int default 0;
while x < 100 do
  update alerts_daily set list_exch = 'OQB' where d_symbol in 
    (select d_symbol from temp_daily where list_exch = 'OQB')
    and date = '2018-06-08' - interval x day 
    and list_exch in ('PINK', 'OTC');
  update alerts_daily set list_exch = 'OQX' where d_symbol in 
    (select d_symbol from temp_daily where list_exch = 'OQX')
    and date = '2018-06-08' - interval x day
    and list_exch in ('PINK', 'OTC');
  set x = x + 1;
end while;
end ;;
DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `otcfixtwo`()
wholeblock:BEGIN
declare x int default 0;
while x < 100 do
  update alerts_daily set list_exch = 'PINK' where list_exch = 'OTC'
    and date = '2018-06-08' - interval x day;
  set x = x + 1;
end while;
END ;;
DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `wait_and_read_alerts`(in start_after bigint)
    READS SQL DATA
    SQL SECURITY INVOKER
begin
   declare last_found bigint;
   declare timeout datetime default now() + interval 15 second;
   loop1: loop
     select max(id) into last_found from alerts;
     if (last_found > start_after) then
       leave loop1;
     end if;
    do sleep(0.004);
     if (now() >= timeout) then
       leave loop1;
     end if;
   end loop loop1;
  select * from alerts where id > start_after order by id limit 3000;
 end ;;
DELIMITER ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `wait_and_read_top_list`(in start_after bigint)
    READS SQL DATA
    SQL SECURITY INVOKER
begin
  declare last_found bigint;
  declare timeout datetime default now() + interval 15 second;
  loop1: loop
    select max(id) into last_found from top_list;
    do sleep(0.004);
    if (last_found > start_after) then
      leave loop1;
    end if;
    if (now() >= timeout) then
      leave loop1;
    end if;
  end loop loop1;
  select * from top_list where id > start_after and id <= last_found order by id limit 1000;
end ;;
DELIMITER ;


