-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Sep 04, 2026 at 10:35 AM
-- Server version: 10.4.22-MariaDB
-- PHP Version: 8.1.2

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
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: `pppl_scoreboard`
--

-- --------------------------------------------------------

--
-- Table structure for table `balls`
--

CREATE TABLE `balls` (
  `id` int(11) NOT NULL,
  `match_id` int(11) NOT NULL,
  `innings` tinyint(4) NOT NULL DEFAULT 1,
  `over_no` int(11) NOT NULL DEFAULT 0,
  `ball_no` int(11) NOT NULL DEFAULT 0,
  `runs` int(11) NOT NULL DEFAULT 0,
  `bat_runs` int(11) NOT NULL DEFAULT 0,
  `extra_runs` int(11) NOT NULL DEFAULT 0,
  `extra_type` enum('none','wd','nb') NOT NULL DEFAULT 'none',
  `is_wicket` tinyint(1) NOT NULL DEFAULT 0,
  `is_legal_ball` tinyint(1) NOT NULL DEFAULT 1,
  `display_text` varchar(20) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `balls`
--

INSERT INTO `balls` (`id`, `match_id`, `innings`, `over_no`, `ball_no`, `runs`, `bat_runs`, `extra_runs`, `extra_type`, `is_wicket`, `is_legal_ball`, `display_text`, `created_at`) VALUES
(748, 84, 1, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-08-31 16:52:24'),
(749, 84, 1, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-08-31 16:52:51'),
(751, 84, 1, 0, 3, 2, 1, 1, 'nb', 0, 0, 'NB+1', '2026-08-31 16:53:33'),
(752, 84, 1, 0, 3, 4, 4, 0, 'none', 0, 1, '4', '2026-08-31 16:53:50'),
(753, 84, 1, 0, 4, 1, 0, 1, 'wd', 0, 0, 'WD', '2026-08-31 16:54:16'),
(754, 84, 1, 0, 4, 6, 6, 0, 'none', 0, 1, '6', '2026-08-31 16:54:37'),
(755, 84, 1, 0, 5, 1, 1, 0, 'none', 0, 1, '1', '2026-08-31 16:54:49'),
(756, 84, 1, 0, 6, 0, 0, 0, 'none', 1, 1, 'W', '2026-08-31 16:54:55'),
(757, 84, 1, 1, 1, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 16:55:24'),
(758, 84, 1, 1, 2, 2, 0, 2, 'wd', 0, 0, 'WD+1', '2026-08-31 16:55:43'),
(759, 84, 1, 1, 2, 5, 0, 5, 'wd', 0, 0, 'WD+4', '2026-08-31 16:55:53'),
(760, 84, 1, 1, 2, 0, 0, 0, 'none', 0, 1, '•', '2026-08-31 16:56:00'),
(761, 84, 1, 1, 3, 4, 4, 0, 'none', 0, 1, '4', '2026-08-31 16:56:14'),
(762, 84, 1, 1, 4, 1, 1, 0, 'none', 0, 1, '1', '2026-08-31 16:56:27'),
(763, 84, 1, 1, 5, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 16:56:34'),
(764, 84, 1, 1, 6, 4, 4, 0, 'none', 0, 1, '4', '2026-08-31 16:56:40'),
(765, 84, 1, 2, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-08-31 16:57:38'),
(766, 84, 1, 2, 2, 0, 0, 0, 'none', 1, 1, 'W', '2026-08-31 16:57:49'),
(767, 84, 1, 2, 3, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-08-31 16:58:04'),
(768, 84, 1, 2, 3, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 16:58:14'),
(769, 84, 1, 2, 4, 3, 3, 0, 'none', 0, 1, '3', '2026-08-31 16:58:43'),
(770, 84, 1, 2, 5, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 16:58:56'),
(771, 84, 1, 2, 6, 4, 4, 0, 'none', 0, 1, '4', '2026-08-31 16:59:12'),
(772, 84, 1, 3, 1, 2, 2, 0, 'none', 1, 1, 'W+2', '2026-08-31 16:59:41'),
(773, 84, 1, 3, 2, 0, 0, 0, 'none', 0, 1, '•', '2026-08-31 16:59:54'),
(774, 84, 1, 3, 3, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 17:00:07'),
(775, 84, 1, 3, 4, 4, 4, 0, 'none', 0, 1, '4', '2026-08-31 17:00:26'),
(776, 84, 1, 3, 5, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 17:00:34'),
(777, 84, 1, 3, 6, 1, 1, 0, 'none', 0, 1, '1', '2026-08-31 17:00:37'),
(778, 84, 2, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-08-31 17:01:48'),
(779, 84, 2, 0, 2, 4, 4, 0, 'none', 0, 1, '4', '2026-08-31 17:02:20'),
(780, 84, 2, 0, 3, 6, 6, 0, 'none', 0, 1, '6', '2026-08-31 17:04:38'),
(781, 84, 2, 0, 4, 4, 4, 0, 'none', 0, 1, '4', '2026-08-31 17:21:34'),
(782, 84, 2, 0, 5, 5, 5, 0, 'none', 0, 1, '5', '2026-08-31 17:21:57'),
(783, 84, 2, 0, 6, 3, 2, 1, 'nb', 0, 0, 'NB+2', '2026-08-31 17:22:07'),
(784, 84, 2, 0, 6, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 17:22:35'),
(785, 84, 2, 1, 1, 4, 4, 0, 'none', 0, 1, '4', '2026-08-31 17:22:44'),
(786, 84, 2, 1, 2, 0, 0, 0, 'none', 1, 1, 'W', '2026-08-31 17:22:47'),
(787, 84, 2, 1, 3, 7, 7, 0, 'none', 0, 1, '7', '2026-08-31 17:23:09'),
(788, 84, 2, 1, 4, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 17:23:25'),
(789, 84, 2, 1, 5, 6, 6, 0, 'none', 0, 1, '6', '2026-08-31 17:23:41'),
(790, 84, 2, 1, 6, 3, 0, 3, 'wd', 0, 0, 'WD+2', '2026-08-31 17:23:54'),
(791, 84, 2, 1, 6, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 17:24:05'),
(792, 84, 2, 2, 1, 3, 3, 0, 'none', 0, 1, '3', '2026-08-31 17:24:27'),
(793, 84, 2, 2, 2, 0, 0, 0, 'none', 0, 1, '•', '2026-08-31 17:25:16'),
(794, 84, 2, 2, 3, 1, 1, 0, 'none', 0, 1, '1', '2026-08-31 17:25:26'),
(795, 84, 2, 2, 4, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 17:25:46'),
(796, 84, 2, 2, 5, 4, 4, 0, 'none', 0, 1, '4', '2026-08-31 17:26:10'),
(797, 84, 2, 2, 6, 0, 0, 0, 'none', 0, 1, '•', '2026-08-31 17:26:33'),
(798, 84, 2, 3, 1, 0, 0, 0, 'none', 1, 1, 'W', '2026-08-31 17:26:41'),
(799, 84, 2, 3, 2, 0, 0, 0, 'none', 1, 1, 'W', '2026-08-31 17:27:05'),
(800, 84, 2, 3, 3, 0, 0, 0, 'none', 1, 1, 'W', '2026-08-31 17:27:28'),
(801, 84, 2, 3, 4, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 17:27:45'),
(802, 84, 2, 3, 5, 1, 0, 1, 'wd', 0, 0, 'WD', '2026-08-31 17:27:59'),
(803, 84, 2, 3, 5, 1, 1, 0, 'none', 0, 1, '1', '2026-08-31 17:28:12'),
(804, 84, 2, 3, 6, 6, 6, 0, 'none', 0, 1, '6', '2026-08-31 17:28:25'),
(805, 85, 1, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-08-31 17:31:22'),
(806, 85, 1, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-08-31 17:31:52'),
(807, 85, 1, 0, 3, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-08-31 17:32:00'),
(808, 85, 1, 0, 3, 1, 1, 0, 'none', 0, 1, '1', '2026-08-31 17:32:09'),
(809, 88, 1, 0, 1, 5, 5, 0, 'none', 0, 1, '5', '2026-08-31 17:34:00'),
(810, 89, 1, 0, 1, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 17:45:17'),
(811, 89, 1, 0, 2, 4, 4, 0, 'none', 0, 1, '4', '2026-08-31 17:45:31'),
(812, 89, 1, 0, 3, 0, 0, 0, 'none', 0, 1, '0', '2026-08-31 17:45:38'),
(813, 89, 1, 0, 4, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-08-31 17:45:54'),
(814, 89, 1, 0, 4, 6, 6, 0, 'none', 0, 1, '6', '2026-08-31 17:46:13'),
(815, 89, 1, 0, 5, 0, 0, 0, 'none', 1, 1, 'W', '2026-08-31 17:46:53'),
(816, 89, 1, 0, 6, 2, 2, 0, 'none', 0, 1, '2', '2026-08-31 17:49:59'),
(817, 89, 1, 1, 1, 5, 0, 5, 'wd', 0, 0, 'WD+4', '2026-08-31 17:50:08'),
(818, 89, 1, 1, 1, 5, 0, 5, 'wd', 0, 0, 'WD+4', '2026-08-31 17:50:19'),
(819, 89, 1, 1, 1, 3, 3, 0, 'none', 0, 1, '3', '2026-08-31 17:50:37');

-- --------------------------------------------------------

--
-- Table structure for table `matches`
--

CREATE TABLE `matches` (
  `id` int(11) NOT NULL,
  `match_no` int(11) NOT NULL,
  `team_a_id` int(11) NOT NULL,
  `team_b_id` int(11) NOT NULL,
  `toss_winner_id` int(11) DEFAULT NULL,
  `toss_choice` enum('bat','field') DEFAULT NULL,
  `batting_team_id` int(11) DEFAULT NULL,
  `bowling_team_id` int(11) DEFAULT NULL,
  `innings` tinyint(4) NOT NULL DEFAULT 1,
  `runs` int(11) NOT NULL DEFAULT 0,
  `wickets` int(11) NOT NULL DEFAULT 0,
  `legal_balls` int(11) NOT NULL DEFAULT 0,
  `extras` int(11) NOT NULL DEFAULT 0,
  `target` int(11) DEFAULT NULL,
  `inning_start_time` datetime DEFAULT NULL,
  `inning_elapsed_seconds` int(11) NOT NULL DEFAULT 0,
  `status` enum('not_started','live','innings_break','super_over','completed') NOT NULL DEFAULT 'not_started',
  `winner_team_id` int(11) DEFAULT NULL,
  `result_text` varchar(255) DEFAULT NULL,
  `manual_result` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `matches`
--

INSERT INTO `matches` (`id`, `match_no`, `team_a_id`, `team_b_id`, `toss_winner_id`, `toss_choice`, `batting_team_id`, `bowling_team_id`, `innings`, `runs`, `wickets`, `legal_balls`, `extras`, `target`, `inning_start_time`, `inning_elapsed_seconds`, `status`, `winner_team_id`, `result_text`, `manual_result`, `created_at`, `updated_at`) VALUES
(84, 1, 17, 19, 19, 'field', 19, 17, 2, 74, 4, 24, 5, 76, NULL, 1605, 'completed', 17, '🏆 GS won by 1 runs', 0, '2026-08-31 16:51:24', '2026-08-31 17:28:25'),
(85, 2, 20, 16, 16, 'bat', 16, 20, 1, 14, 0, 3, 1, NULL, NULL, 76, 'completed', 20, '🏆 RSW won the match', 1, '2026-08-31 17:30:58', '2026-08-31 17:32:21'),
(88, 3, 23, 18, 23, 'field', 18, 23, 1, 5, 0, 1, 0, NULL, NULL, 21, 'completed', 23, '🏆 NS won the match', 1, '2026-08-31 17:33:42', '2026-08-31 17:34:07'),
(89, 4, 22, 21, 22, 'bat', 22, 21, 1, 28, 1, 7, 11, NULL, NULL, 391, 'completed', 21, '🏆 USK won the match', 1, '2026-08-31 17:34:21', '2026-08-31 17:51:40');

-- --------------------------------------------------------

--
-- Table structure for table `match_innings`
--

CREATE TABLE `match_innings` (
  `id` int(11) NOT NULL,
  `match_id` int(11) NOT NULL,
  `innings_no` tinyint(4) NOT NULL,
  `batting_team_id` int(11) NOT NULL,
  `bowling_team_id` int(11) NOT NULL,
  `runs` int(11) NOT NULL DEFAULT 0,
  `wickets` int(11) NOT NULL DEFAULT 0,
  `legal_balls` int(11) NOT NULL DEFAULT 0,
  `extras` int(11) NOT NULL DEFAULT 0,
  `target` int(11) DEFAULT NULL,
  `start_time` datetime DEFAULT NULL,
  `end_time` datetime DEFAULT NULL,
  `elapsed_seconds` int(11) NOT NULL DEFAULT 0,
  `status` enum('not_started','live','completed') NOT NULL DEFAULT 'not_started',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `match_innings`
--

INSERT INTO `match_innings` (`id`, `match_id`, `innings_no`, `batting_team_id`, `bowling_team_id`, `runs`, `wickets`, `legal_balls`, `extras`, `target`, `start_time`, `end_time`, `elapsed_seconds`, `status`, `created_at`, `updated_at`) VALUES
(131, 84, 1, 17, 19, 75, 3, 24, 10, NULL, NULL, '2026-08-31 22:30:38', 512, 'completed', '2026-08-31 16:51:24', '2026-08-31 17:00:38'),
(132, 84, 2, 19, 17, 74, 4, 24, 5, 76, NULL, '2026-08-31 22:58:25', 1606, 'completed', '2026-08-31 17:01:39', '2026-08-31 17:28:25'),
(133, 85, 1, 16, 20, 14, 0, 3, 1, NULL, NULL, '2026-08-31 23:02:21', 76, 'completed', '2026-08-31 17:30:58', '2026-08-31 17:32:21'),
(136, 88, 1, 18, 23, 5, 0, 1, 0, NULL, NULL, '2026-08-31 23:04:07', 21, 'completed', '2026-08-31 17:33:42', '2026-08-31 17:34:07'),
(137, 89, 1, 22, 21, 28, 1, 7, 11, NULL, NULL, '2026-08-31 23:21:40', 389, 'completed', '2026-08-31 17:34:21', '2026-08-31 17:51:40');

-- --------------------------------------------------------

--
-- Table structure for table `points_table`
--

CREATE TABLE `points_table` (
  `id` int(11) NOT NULL,
  `team_id` int(11) NOT NULL,
  `played` int(11) NOT NULL DEFAULT 0,
  `won` int(11) NOT NULL DEFAULT 0,
  `lost` int(11) NOT NULL DEFAULT 0,
  `tied` int(11) NOT NULL DEFAULT 0,
  `points` int(11) NOT NULL DEFAULT 0,
  `runs_for` int(11) NOT NULL DEFAULT 0,
  `balls_faced` int(11) NOT NULL DEFAULT 0,
  `runs_against` int(11) NOT NULL DEFAULT 0,
  `balls_bowled` int(11) NOT NULL DEFAULT 0,
  `nrr` decimal(8,3) NOT NULL DEFAULT 0.000,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `points_table`
--

INSERT INTO `points_table` (`id`, `team_id`, `played`, `won`, `lost`, `tied`, `points`, `runs_for`, `balls_faced`, `runs_against`, `balls_bowled`, `nrr`, `created_at`, `updated_at`) VALUES
(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-24 13:11:16', '2026-05-25 17:03:00'),
(2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-24 13:11:16', '2026-05-26 16:04:19'),
(3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-24 13:11:16', '2026-05-25 17:03:00'),
(21, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-24 13:13:33', '2026-05-26 16:04:18'),
(2217, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-25 15:13:34', '2026-05-25 17:03:00'),
(2223, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-25 15:13:53', '2026-05-26 16:04:19'),
(2741, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-25 17:12:49', '2026-05-25 17:12:49'),
(2742, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-25 17:13:00', '2026-05-26 16:04:19'),
(2743, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-25 17:14:02', '2026-05-26 16:04:18'),
(2965, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-25 17:44:23', '2026-05-28 15:14:29'),
(2969, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-25 17:44:35', '2026-05-28 14:48:26'),
(2973, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-25 17:44:44', '2026-05-28 15:14:29'),
(2977, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-25 17:44:55', '2026-05-28 15:14:28'),
(4866, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-26 16:04:46', '2026-05-28 14:48:26'),
(4870, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-26 16:05:01', '2026-05-28 14:48:26'),
(7222, 16, 1, 0, 1, 0, 0, 14, 3, 0, 0, '28.000', '2026-05-28 15:18:18', '2026-08-31 17:51:40'),
(7227, 17, 1, 1, 0, 0, 2, 75, 24, 74, 24, '0.250', '2026-05-28 15:18:30', '2026-08-31 17:51:40'),
(7231, 18, 1, 0, 1, 0, 0, 5, 1, 0, 0, '30.000', '2026-05-28 15:18:41', '2026-08-31 17:51:40'),
(7235, 19, 1, 0, 1, 0, 0, 74, 24, 75, 24, '-0.250', '2026-05-28 15:18:53', '2026-08-31 17:51:40'),
(7239, 20, 1, 1, 0, 0, 2, 0, 0, 14, 3, '-28.000', '2026-05-28 15:19:01', '2026-08-31 17:51:40'),
(7243, 21, 1, 1, 0, 0, 2, 0, 0, 28, 7, '-24.000', '2026-05-28 15:19:09', '2026-08-31 17:51:40'),
(7246, 22, 1, 0, 1, 0, 0, 28, 7, 0, 0, '24.000', '2026-05-28 15:19:18', '2026-08-31 17:51:40'),
(11697, 23, 1, 1, 0, 0, 2, 0, 0, 5, 1, '-30.000', '2026-07-03 14:45:31', '2026-08-31 17:51:40');

-- --------------------------------------------------------

--
-- Table structure for table `teams`
--

CREATE TABLE `teams` (
  `id` int(11) NOT NULL,
  `team_name` varchar(140) NOT NULL,
  `short_name` varchar(15) NOT NULL,
  `squad_players_count` int(11) NOT NULL DEFAULT 11,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `teams`
--

INSERT INTO `teams` (`id`, `team_name`, `short_name`, `squad_players_count`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 'Royal Charles', 'RC', 11, 0, '2026-05-24 13:11:16', '2026-05-25 17:44:07'),
(2, 'Dream Cricket', 'DC', 11, 0, '2026-05-24 13:11:16', '2026-05-25 17:43:47'),
(3, 'Warriors', 'WA', 11, 0, '2026-05-24 13:11:16', '2026-05-25 17:44:11'),
(4, 'Diman Point', 'DP', 11, 0, '2026-05-24 13:13:33', '2026-05-25 17:43:44'),
(5, 'Kadawatha Mari', 'KM', 11, 0, '2026-05-25 15:13:34', '2026-05-25 17:43:51'),
(6, 'Pelding Agree Nud', 'PAN', 11, 0, '2026-05-25 15:13:53', '2026-05-25 17:44:02'),
(7, 'Royal Charles', 'RC', 11, 0, '2026-05-25 17:12:49', '2026-05-25 17:43:34'),
(8, 'Nihal Meri', 'NM', 11, 0, '2026-05-25 17:13:00', '2026-05-25 17:43:56'),
(9, 'fffff', 'FF', 11, 0, '2026-05-25 17:14:02', '2026-05-25 17:43:41'),
(10, 'RC Homagama', 'RH', 8, 0, '2026-05-25 17:44:23', '2026-05-28 15:18:14'),
(11, 'Diyagama Falcons', 'DF', 8, 0, '2026-05-25 17:44:35', '2026-05-28 15:18:03'),
(12, 'Homagama Sixers', 'HS', 8, 0, '2026-05-25 17:44:43', '2026-05-28 15:18:05'),
(13, 'BA Engineering', 'BE', 8, 0, '2026-05-25 17:44:55', '2026-05-28 15:18:00'),
(14, 'NSS6', 'NS', 11, 0, '2026-05-26 16:04:46', '2026-05-28 15:18:12'),
(15, 'M SMoters', 'MS', 11, 0, '2026-05-26 16:05:01', '2026-05-28 15:18:09'),
(16, 'Prasannapura CC', 'PC', 11, 1, '2026-05-28 15:18:18', '2026-05-28 15:18:18'),
(17, 'GC Strikers', 'GS', 11, 1, '2026-05-28 15:18:30', '2026-05-28 15:18:30'),
(18, 'Diyagama Falcons', 'DF', 11, 1, '2026-05-28 15:18:41', '2026-05-28 15:18:41'),
(19, 'Homagama Sixers', 'HS', 11, 1, '2026-05-28 15:18:53', '2026-05-28 15:18:53'),
(20, 'RS Sport Wears', 'RSW', 11, 1, '2026-05-28 15:19:01', '2026-05-28 15:19:01'),
(21, 'Uduwana Super Kings', 'USK', 11, 1, '2026-05-28 15:19:09', '2026-05-28 15:19:09'),
(22, 'Savi Stores', 'SS', 11, 1, '2026-05-28 15:19:18', '2026-05-28 15:19:18'),
(23, 'NS6', 'NS', 11, 1, '2026-07-03 14:45:31', '2026-07-03 14:45:31');

-- --------------------------------------------------------

--
-- Table structure for table `tournament_settings`
--

CREATE TABLE `tournament_settings` (
  `id` int(11) NOT NULL,
  `tournament_name` varchar(180) NOT NULL DEFAULT 'Prasannapura Premier League',
  `squad_players_count` int(11) NOT NULL DEFAULT 11,
  `overs` int(11) NOT NULL DEFAULT 8,
  `balls_per_over` int(11) NOT NULL DEFAULT 6,
  `inning_minutes` int(11) NOT NULL DEFAULT 20,
  `display_mode` enum('scoreboard','sponsors','special','organized','managers','star_players','points_table','theme_song','tournament_completed') NOT NULL DEFAULT 'scoreboard',
  `special_message` text DEFAULT NULL,
  `tournament_winner_team_id` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `tournament_settings`
--

INSERT INTO `tournament_settings` (`id`, `tournament_name`, `squad_players_count`, `overs`, `balls_per_over`, `inning_minutes`, `display_mode`, `special_message`, `tournament_winner_team_id`, `created_at`, `updated_at`) VALUES
(1, 'PPPL - LIVE scoreboard', 11, 4, 6, 16, 'scoreboard', NULL, NULL, '2026-05-24 13:11:16', '2026-08-31 17:46:49');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `balls`
--
ALTER TABLE `balls`
  ADD PRIMARY KEY (`id`),
  ADD KEY `match_id` (`match_id`,`innings`),
  ADD KEY `created_at` (`created_at`);

--
-- Indexes for table `matches`
--
ALTER TABLE `matches`
  ADD PRIMARY KEY (`id`),
  ADD KEY `team_a_id` (`team_a_id`),
  ADD KEY `team_b_id` (`team_b_id`),
  ADD KEY `toss_winner_id` (`toss_winner_id`),
  ADD KEY `batting_team_id` (`batting_team_id`),
  ADD KEY `bowling_team_id` (`bowling_team_id`),
  ADD KEY `winner_team_id` (`winner_team_id`),
  ADD KEY `status` (`status`),
  ADD KEY `match_no` (`match_no`);

--
-- Indexes for table `match_innings`
--
ALTER TABLE `match_innings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_match_innings` (`match_id`,`innings_no`),
  ADD KEY `batting_team_id` (`batting_team_id`),
  ADD KEY `bowling_team_id` (`bowling_team_id`);

--
-- Indexes for table `points_table`
--
ALTER TABLE `points_table`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `team_id` (`team_id`);

--
-- Indexes for table `teams`
--
ALTER TABLE `teams`
  ADD PRIMARY KEY (`id`),
  ADD KEY `is_active` (`is_active`);

--
-- Indexes for table `tournament_settings`
--
ALTER TABLE `tournament_settings`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `balls`
--
ALTER TABLE `balls`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=820;

--
-- AUTO_INCREMENT for table `matches`
--
ALTER TABLE `matches`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=90;

--
-- AUTO_INCREMENT for table `match_innings`
--
ALTER TABLE `match_innings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=138;

--
-- AUTO_INCREMENT for table `points_table`
--
ALTER TABLE `points_table`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11715;

--
-- AUTO_INCREMENT for table `teams`
--
ALTER TABLE `teams`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;

--
-- AUTO_INCREMENT for table `tournament_settings`
--
ALTER TABLE `tournament_settings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `balls`
--
ALTER TABLE `balls`
  ADD CONSTRAINT `balls_ibfk_1` FOREIGN KEY (`match_id`) REFERENCES `matches` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `matches`
--
ALTER TABLE `matches`
  ADD CONSTRAINT `matches_ibfk_1` FOREIGN KEY (`team_a_id`) REFERENCES `teams` (`id`),
  ADD CONSTRAINT `matches_ibfk_2` FOREIGN KEY (`team_b_id`) REFERENCES `teams` (`id`),
  ADD CONSTRAINT `matches_ibfk_3` FOREIGN KEY (`toss_winner_id`) REFERENCES `teams` (`id`),
  ADD CONSTRAINT `matches_ibfk_4` FOREIGN KEY (`batting_team_id`) REFERENCES `teams` (`id`),
  ADD CONSTRAINT `matches_ibfk_5` FOREIGN KEY (`bowling_team_id`) REFERENCES `teams` (`id`),
  ADD CONSTRAINT `matches_ibfk_6` FOREIGN KEY (`winner_team_id`) REFERENCES `teams` (`id`);

--
-- Constraints for table `match_innings`
--
ALTER TABLE `match_innings`
  ADD CONSTRAINT `match_innings_ibfk_1` FOREIGN KEY (`match_id`) REFERENCES `matches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `match_innings_ibfk_2` FOREIGN KEY (`batting_team_id`) REFERENCES `teams` (`id`),
  ADD CONSTRAINT `match_innings_ibfk_3` FOREIGN KEY (`bowling_team_id`) REFERENCES `teams` (`id`);

--
-- Constraints for table `points_table`
--
ALTER TABLE `points_table`
  ADD CONSTRAINT `points_table_ibfk_1` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE;
COMMIT;

/*!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 */;
