text: -- phpMyAdmin SQL Dump
  -- version 4.5.4.1deb2ubuntu2
  -- http://www.phpmyadmin.net
  --
  -- Host: localhost
  -- Generation Time: May 11, 2017 at 07:57 PM
  -- Server version: 5.7.17-0ubuntu0.16.04.1
  -- PHP Version: 5.6.30-10+deb.sury.org~xenial+2
  
  SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  SET time_zone = "+00:00";
  
  
  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  /*!40101 SET NAMES utf8mb4 */;
  
  --
  -- Database: `syn`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `ball_type`
  --
  
  CREATE TABLE `ball_type` (
    `id` int(11) NOT NULL,
    `game_id` int(11) DEFAULT NULL,
    `hierarchy` int(11) DEFAULT NULL,
    `name` varchar(50) DEFAULT NULL,
    `quantity_in_pot` int(11) DEFAULT NULL,
    `quantity_drawn` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `choice`
  --
  
  CREATE TABLE `choice` (
    `id` int(11) NOT NULL,
    `line_id` int(11) DEFAULT NULL,
    `chosen_number` int(11) DEFAULT NULL,
    `position` int(11) DEFAULT NULL,
    `ball_hierarchy` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `country`
  --
  
  CREATE TABLE `country` (
    `id` int(11) NOT NULL,
    `name` varchar(150) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `draw`
  --
  
  CREATE TABLE `draw` (
    `id` int(11) NOT NULL,
    `game_id` int(11) DEFAULT NULL,
    `draw_date` datetime DEFAULT NULL,
    `est_jackpot` decimal(20,2) DEFAULT NULL,
    `cutoff_date` datetime DEFAULT NULL,
    `draw_status_id` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `draw_status`
  --
  
  CREATE TABLE `draw_status` (
    `id` int(11) NOT NULL,
    `name` varchar(50) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `game`
  --
  
  CREATE TABLE `game` (
    `id` int(11) NOT NULL,
    `name` varchar(50) DEFAULT NULL,
    `country_id` int(11) DEFAULT NULL,
    `price_per_line` decimal(10,2) DEFAULT NULL,
    `logo_path` varchar(150) DEFAULT NULL,
    `next_draw_id` int(11) DEFAULT NULL,
    `active` tinyint(4) DEFAULT NULL,
    `draw_frequency` varchar(20) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `line`
  --
  
  CREATE TABLE `line` (
    `id` int(11) NOT NULL,
    `game_id` int(11) DEFAULT NULL,
    `draw_id` int(11) DEFAULT NULL,
    `ticket_id` int(11) DEFAULT NULL,
    `line_status_id` int(11) DEFAULT '1',
    `syndicate_id` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `line_status`
  --
  
  CREATE TABLE `line_status` (
    `id` int(11) NOT NULL,
    `name` varchar(50) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `migration`
  --
  
  CREATE TABLE `migration` (
    `version` varchar(180) NOT NULL,
    `apply_time` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `privacy_level`
  --
  
  CREATE TABLE `privacy_level` (
    `id` int(11) NOT NULL,
    `name` varchar(50) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `prize`
  --
  
  CREATE TABLE `prize` (
    `id` int(11) NOT NULL,
    `game_id` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `profile`
  --
  
  CREATE TABLE `profile` (
    `user_id` int(11) NOT NULL,
    `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    `public_email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    `gravatar_email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    `gravatar_id` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
    `location` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    `website` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    `bio` text COLLATE utf8_unicode_ci,
    `timezone` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `result`
  --
  
  CREATE TABLE `result` (
    `id` int(11) NOT NULL,
    `draw_id` int(11) DEFAULT NULL,
    `drawn_number` int(11) DEFAULT NULL,
    `position` int(11) DEFAULT NULL,
    `ball_category_id` int(11) DEFAULT NULL,
    `ball_hierarchy` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `signup_method`
  --
  
  CREATE TABLE `signup_method` (
    `id` int(11) NOT NULL,
    `name` varchar(50) DEFAULT NULL,
    `is_social_media` tinyint(4) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `social_account`
  --
  
  CREATE TABLE `social_account` (
    `id` int(11) NOT NULL,
    `user_id` int(11) DEFAULT NULL,
    `provider` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `client_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `data` text COLLATE utf8_unicode_ci,
    `code` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
    `created_at` int(11) DEFAULT NULL,
    `email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    `username` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `subscription`
  --
  
  CREATE TABLE `subscription` (
    `id` int(11) NOT NULL,
    `user_id` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `syndicate`
  --
  
  CREATE TABLE `syndicate` (
    `id` int(11) NOT NULL,
    `draw_id` int(11) DEFAULT NULL,
    `creator_user_id` int(11) DEFAULT NULL,
    `num_lines` int(11) DEFAULT NULL,
    `num_shares` int(11) DEFAULT NULL,
    `cost_per_share` decimal(10,2) DEFAULT NULL,
    `syndie_style` tinyint(4) DEFAULT '0',
    `syndie_lines_per_person` int(11) DEFAULT NULL,
    `number_of_draws` int(11) DEFAULT NULL,
    `min_players` int(11) DEFAULT '1',
    `max_players` int(11) DEFAULT '0',
    `syndicate_status_id` int(11) DEFAULT '1',
    `name` varchar(100) DEFAULT NULL,
    `message` varchar(255) DEFAULT NULL,
    `privacy_level_id` int(11) DEFAULT NULL,
    `game_id` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `syndicate_member`
  --
  
  CREATE TABLE `syndicate_member` (
    `syndicate_id` int(11) DEFAULT NULL,
    `user_id` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `syndicate_status`
  --
  
  CREATE TABLE `syndicate_status` (
    `id` int(11) NOT NULL,
    `name` varchar(50) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `ticket`
  --
  
  CREATE TABLE `ticket` (
    `id` int(11) NOT NULL,
    `value` decimal(10,2) DEFAULT NULL,
    `user_id` int(11) DEFAULT NULL,
    `transaction_id` int(11) DEFAULT NULL,
    `ticket_status_id` int(11) DEFAULT NULL,
    `syndicate_id` int(11) DEFAULT NULL,
    `game_id` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `ticket_status`
  --
  
  CREATE TABLE `ticket_status` (
    `id` int(11) NOT NULL,
    `name` varchar(45) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `token`
  --
  
  CREATE TABLE `token` (
    `user_id` int(11) NOT NULL,
    `code` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
    `created_at` int(11) NOT NULL,
    `type` smallint(6) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `transaction`
  --
  
  CREATE TABLE `transaction` (
    `id` int(11) NOT NULL,
    `transaction_status_id` int(11) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `transaction_history`
  --
  
  CREATE TABLE `transaction_history` (
    `id` int(11) NOT NULL,
    `user_id` int(11) DEFAULT NULL,
    `transaction_date` datetime DEFAULT NULL,
    `amount` decimal(10,2) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `transaction_status`
  --
  
  CREATE TABLE `transaction_status` (
    `id` int(11) NOT NULL,
    `name` varchar(100) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `user`
  --
  
  CREATE TABLE `user` (
    `id` int(11) NOT NULL,
    `username` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `password_hash` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
    `auth_key` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
    `confirmed_at` int(11) DEFAULT NULL,
    `unconfirmed_email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
    `blocked_at` int(11) DEFAULT NULL,
    `registration_ip` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
    `created_at` int(11) NOT NULL,
    `updated_at` int(11) NOT NULL,
    `flags` int(11) NOT NULL DEFAULT '0',
    `last_login_at` int(11) DEFAULT NULL,
    `is_affiliate` tinyint(4) DEFAULT NULL,
    `is_sponsor` tinyint(4) DEFAULT NULL,
    `commission_rate` decimal(10,2) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `wallet`
  --
  
  CREATE TABLE `wallet` (
    `id` int(11) NOT NULL,
    `user_id` int(11) DEFAULT NULL,
    `balance` decimal(10,2) DEFAULT '0.00',
    `reserved_balance` decimal(10,2) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `ball_type`
  --
  ALTER TABLE `ball_type`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_bt_game_idx` (`game_id`);
  
  --
  -- Indexes for table `choice`
  --
  ALTER TABLE `choice`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_choice_line_idx` (`line_id`);
  
  --
  -- Indexes for table `country`
  --
  ALTER TABLE `country`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `draw`
  --
  ALTER TABLE `draw`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_draw_game_idx` (`game_id`),
    ADD KEY `fk_draw_status_idx` (`draw_status_id`);
  
  --
  -- Indexes for table `draw_status`
  --
  ALTER TABLE `draw_status`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `game`
  --
  ALTER TABLE `game`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_game_country_idx` (`country_id`),
    ADD KEY `fk_game_draw_idx` (`next_draw_id`);
  
  --
  -- Indexes for table `line`
  --
  ALTER TABLE `line`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_line_game_idx` (`game_id`),
    ADD KEY `fk_line_ti_idx` (`ticket_id`),
    ADD KEY `fk_line_ls_idx` (`line_status_id`),
    ADD KEY `fk_line_syndi_idx` (`syndicate_id`);
  
  --
  -- Indexes for table `line_status`
  --
  ALTER TABLE `line_status`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `migration`
  --
  ALTER TABLE `migration`
    ADD PRIMARY KEY (`version`);
  
  --
  -- Indexes for table `privacy_level`
  --
  ALTER TABLE `privacy_level`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `prize`
  --
  ALTER TABLE `prize`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_prize_game` (`game_id`);
  
  --
  -- Indexes for table `profile`
  --
  ALTER TABLE `profile`
    ADD PRIMARY KEY (`user_id`);
  
  --
  -- Indexes for table `result`
  --
  ALTER TABLE `result`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_results_draw_idx` (`draw_id`),
    ADD KEY `fk_results_bc_idx` (`ball_category_id`);
  
  --
  -- Indexes for table `signup_method`
  --
  ALTER TABLE `signup_method`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `social_account`
  --
  ALTER TABLE `social_account`
    ADD PRIMARY KEY (`id`),
    ADD UNIQUE KEY `account_unique` (`provider`,`client_id`),
    ADD UNIQUE KEY `account_unique_code` (`code`),
    ADD KEY `fk_user_account` (`user_id`);
  
  --
  -- Indexes for table `subscription`
  --
  ALTER TABLE `subscription`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_sub_user_idx` (`user_id`);
  
  --
  -- Indexes for table `syndicate`
  --
  ALTER TABLE `syndicate`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_syndi_draw_idx` (`draw_id`),
    ADD KEY `fk_syndi_user_idx` (`creator_user_id`),
    ADD KEY `fk_syndi_status_idx` (`syndicate_status_id`),
    ADD KEY `fk_syndi_privacy_idx` (`privacy_level_id`),
    ADD KEY `fk_syndi_game_idx` (`game_id`);
  
  --
  -- Indexes for table `syndicate_member`
  --
  ALTER TABLE `syndicate_member`
    ADD KEY `fk_sm_synd_idx` (`syndicate_id`),
    ADD KEY `fk_sm_user_idx` (`user_id`);
  
  --
  -- Indexes for table `syndicate_status`
  --
  ALTER TABLE `syndicate_status`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `ticket`
  --
  ALTER TABLE `ticket`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_ti_user_idx` (`user_id`),
    ADD KEY `fk_tick_stat_idx` (`ticket_status_id`),
    ADD KEY `fk_tick_trans_idx` (`transaction_id`),
    ADD KEY `fk_tick_syn_idx` (`syndicate_id`),
    ADD KEY `fk_tick_game_idx` (`game_id`);
  
  --
  -- Indexes for table `ticket_status`
  --
  ALTER TABLE `ticket_status`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `token`
  --
  ALTER TABLE `token`
    ADD UNIQUE KEY `token_unique` (`user_id`,`code`,`type`);
  
  --
  -- Indexes for table `transaction`
  --
  ALTER TABLE `transaction`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_trans_trans_status_idx` (`transaction_status_id`);
  
  --
  -- Indexes for table `transaction_history`
  --
  ALTER TABLE `transaction_history`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `transaction_status`
  --
  ALTER TABLE `transaction_status`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `user`
  --
  ALTER TABLE `user`
    ADD PRIMARY KEY (`id`),
    ADD UNIQUE KEY `user_unique_username` (`username`),
    ADD UNIQUE KEY `user_unique_email` (`email`);
  
  --
  -- Indexes for table `wallet`
  --
  ALTER TABLE `wallet`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fk_wallet_user_idx` (`user_id`);
  
  --
  -- AUTO_INCREMENT for dumped tables
  --
  
  --
  -- AUTO_INCREMENT for table `ball_type`
  --
  ALTER TABLE `ball_type`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `choice`
  --
  ALTER TABLE `choice`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `country`
  --
  ALTER TABLE `country`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `draw`
  --
  ALTER TABLE `draw`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `draw_status`
  --
  ALTER TABLE `draw_status`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `game`
  --
  ALTER TABLE `game`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `line`
  --
  ALTER TABLE `line`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `line_status`
  --
  ALTER TABLE `line_status`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `privacy_level`
  --
  ALTER TABLE `privacy_level`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `prize`
  --
  ALTER TABLE `prize`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `result`
  --
  ALTER TABLE `result`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `signup_method`
  --
  ALTER TABLE `signup_method`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `social_account`
  --
  ALTER TABLE `social_account`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `subscription`
  --
  ALTER TABLE `subscription`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `syndicate`
  --
  ALTER TABLE `syndicate`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `syndicate_status`
  --
  ALTER TABLE `syndicate_status`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `ticket`
  --
  ALTER TABLE `ticket`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `ticket_status`
  --
  ALTER TABLE `ticket_status`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `transaction`
  --
  ALTER TABLE `transaction`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `transaction_history`
  --
  ALTER TABLE `transaction_history`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `transaction_status`
  --
  ALTER TABLE `transaction_status`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `user`
  --
  ALTER TABLE `user`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- AUTO_INCREMENT for table `wallet`
  --
  ALTER TABLE `wallet`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  --
  -- Constraints for dumped tables
  --
  
  --
  -- Constraints for table `ball_type`
  --
  ALTER TABLE `ball_type`
    ADD CONSTRAINT `fk_bt_game` FOREIGN KEY (`game_id`) REFERENCES `game` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `choice`
  --
  ALTER TABLE `choice`
    ADD CONSTRAINT `fk_choice_line` FOREIGN KEY (`line_id`) REFERENCES `line` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `draw`
  --
  ALTER TABLE `draw`
    ADD CONSTRAINT `fk_draw_game` FOREIGN KEY (`game_id`) REFERENCES `game` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_draw_status` FOREIGN KEY (`draw_status_id`) REFERENCES `draw` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `game`
  --
  ALTER TABLE `game`
    ADD CONSTRAINT `fk_game_country` FOREIGN KEY (`country_id`) REFERENCES `country` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_game_draw` FOREIGN KEY (`next_draw_id`) REFERENCES `draw` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `line`
  --
  ALTER TABLE `line`
    ADD CONSTRAINT `fk_line_game` FOREIGN KEY (`game_id`) REFERENCES `game` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_line_ls` FOREIGN KEY (`line_status_id`) REFERENCES `line_status` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_line_syndi` FOREIGN KEY (`syndicate_id`) REFERENCES `syndicate` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_line_ti` FOREIGN KEY (`ticket_id`) REFERENCES `ticket` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `prize`
  --
  ALTER TABLE `prize`
    ADD CONSTRAINT `fk_prize_game` FOREIGN KEY (`game_id`) REFERENCES `game` (`id`);
  
  --
  -- Constraints for table `profile`
  --
  ALTER TABLE `profile`
    ADD CONSTRAINT `fk_user_profile` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE;
  
  --
  -- Constraints for table `result`
  --
  ALTER TABLE `result`
    ADD CONSTRAINT `fk_results_draw` FOREIGN KEY (`draw_id`) REFERENCES `draw` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `social_account`
  --
  ALTER TABLE `social_account`
    ADD CONSTRAINT `fk_user_account` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE;
  
  --
  -- Constraints for table `subscription`
  --
  ALTER TABLE `subscription`
    ADD CONSTRAINT `fk_sub_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `syndicate`
  --
  ALTER TABLE `syndicate`
    ADD CONSTRAINT `fk_syndi_draw` FOREIGN KEY (`draw_id`) REFERENCES `draw` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_syndi_game` FOREIGN KEY (`game_id`) REFERENCES `game` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_syndi_privacy` FOREIGN KEY (`privacy_level_id`) REFERENCES `privacy_level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_syndi_status` FOREIGN KEY (`syndicate_status_id`) REFERENCES `syndicate_status` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_syndi_user` FOREIGN KEY (`creator_user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `syndicate_member`
  --
  ALTER TABLE `syndicate_member`
    ADD CONSTRAINT `fk_sm_synd` FOREIGN KEY (`syndicate_id`) REFERENCES `syndicate` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_sm_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `ticket`
  --
  ALTER TABLE `ticket`
    ADD CONSTRAINT `fk_ti_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_tick_game` FOREIGN KEY (`game_id`) REFERENCES `game` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_tick_stat` FOREIGN KEY (`ticket_status_id`) REFERENCES `ticket_status` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_tick_syn` FOREIGN KEY (`syndicate_id`) REFERENCES `syndicate` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_tick_trans` FOREIGN KEY (`transaction_id`) REFERENCES `transaction` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `token`
  --
  ALTER TABLE `token`
    ADD CONSTRAINT `fk_user_token` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE;
  
  --
  -- Constraints for table `transaction`
  --
  ALTER TABLE `transaction`
    ADD CONSTRAINT `fk_trans_trans_status` FOREIGN KEY (`transaction_status_id`) REFERENCES `transaction_status` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `wallet`
  --
  ALTER TABLE `wallet`
    ADD CONSTRAINT `fk_wallet_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  