-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 30, 2026 at 04:52 PM
-- 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
(481, 49, 1, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 15:22:59'),
(482, 49, 1, 0, 2, 4, 4, 0, 'none', 0, 1, '4', '2026-05-28 15:23:04'),
(483, 49, 2, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 15:23:14'),
(484, 49, 2, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 15:23:16'),
(485, 50, 1, 0, 1, 4, 4, 0, 'none', 0, 1, '4', '2026-05-28 15:23:53'),
(486, 50, 1, 0, 2, 0, 0, 0, 'none', 1, 1, 'W', '2026-05-28 15:23:56'),
(487, 50, 2, 0, 1, 3, 3, 0, 'none', 0, 1, '3', '2026-05-28 15:24:05'),
(488, 50, 2, 0, 2, 2, 2, 0, 'none', 0, 1, '2', '2026-05-28 15:24:08'),
(489, 51, 1, 0, 1, 2, 2, 0, 'none', 0, 1, '2', '2026-05-28 15:24:33'),
(490, 51, 1, 0, 2, 5, 5, 0, 'none', 0, 1, '5', '2026-05-28 15:24:36'),
(491, 51, 2, 0, 1, 3, 3, 0, 'none', 0, 1, '3', '2026-05-28 15:24:47'),
(492, 51, 2, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 15:24:49'),
(493, 52, 1, 0, 1, 4, 4, 0, 'none', 0, 1, '4', '2026-05-28 15:25:11'),
(494, 52, 1, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 15:25:14'),
(495, 52, 2, 0, 1, 4, 4, 0, 'none', 0, 1, '4', '2026-05-28 15:25:25'),
(496, 52, 2, 0, 2, 4, 4, 0, 'none', 0, 1, '4', '2026-05-28 15:25:28'),
(497, 53, 1, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 15:25:53'),
(498, 53, 1, 0, 2, 0, 0, 0, 'none', 1, 1, 'W', '2026-05-28 15:26:01'),
(499, 53, 2, 0, 1, 1, 0, 1, 'wd', 0, 0, 'WD', '2026-05-28 15:26:12'),
(500, 53, 2, 0, 1, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-05-28 15:26:24'),
(501, 53, 2, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 15:26:41'),
(502, 54, 1, 0, 1, 4, 4, 0, 'none', 0, 1, '4', '2026-05-28 17:52:34'),
(503, 54, 1, 0, 2, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-05-28 17:52:40'),
(504, 54, 1, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 17:52:46'),
(505, 54, 2, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 18:11:51'),
(506, 54, 2, 0, 2, 5, 5, 0, 'none', 0, 1, '5', '2026-05-28 18:11:58'),
(507, 55, 1, 0, 1, 4, 4, 0, 'none', 0, 1, '4', '2026-05-28 18:37:16'),
(508, 55, 1, 0, 2, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-05-28 18:37:25'),
(509, 55, 1, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 18:37:42'),
(510, 55, 2, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 18:37:53'),
(511, 55, 2, 0, 2, 1, 0, 1, 'wd', 0, 0, 'WD', '2026-05-28 18:38:10'),
(512, 55, 2, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-05-28 18:38:25'),
(513, 56, 1, 0, 1, 4, 4, 0, 'none', 0, 1, '4', '2026-05-29 16:51:52'),
(514, 56, 1, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-05-29 16:52:03'),
(515, 56, 2, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-05-29 16:52:18'),
(516, 56, 2, 0, 2, 4, 4, 0, 'none', 0, 1, '4', '2026-05-29 16:52:27'),
(517, 57, 1, 0, 1, 4, 4, 0, 'none', 0, 1, '4', '2026-05-30 10:12:17'),
(518, 57, 1, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-05-30 10:12:29'),
(519, 57, 2, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-05-30 10:12:41'),
(520, 57, 2, 0, 2, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-05-30 10:12:52'),
(521, 57, 2, 0, 2, 0, 0, 0, 'none', 1, 1, 'W', '2026-05-30 10:13:03'),
(522, 58, 1, 0, 1, 0, 0, 0, 'none', 1, 1, 'W', '2026-05-30 10:17:24'),
(523, 58, 1, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-05-30 10:55:35'),
(524, 58, 1, 0, 3, 4, 4, 0, 'none', 0, 1, '4', '2026-05-30 10:55:59'),
(525, 58, 1, 0, 4, 0, 0, 0, 'none', 1, 1, 'W', '2026-05-30 10:56:22'),
(526, 58, 1, 0, 5, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-05-30 10:56:53'),
(527, 58, 1, 0, 5, 6, 6, 0, 'none', 0, 1, '6', '2026-05-30 10:58:17');

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

--
-- 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
(49, 1, 18, 17, 18, 'field', 18, 17, 2, 12, 0, 2, 0, 11, NULL, 4, 'completed', 18, '🏆 DF won by 10 wickets', 0, '2026-05-28 15:20:38', '2026-05-28 15:23:16'),
(50, 2, 19, 16, 19, 'bat', 16, 19, 2, 5, 0, 2, 0, 5, NULL, 7, 'completed', 16, '🏆 PC won by 10 wickets', 0, '2026-05-28 15:23:33', '2026-05-28 15:24:08'),
(51, 3, 20, 22, 20, 'bat', 22, 20, 2, 9, 0, 2, 0, 8, NULL, 5, 'completed', 22, '🏆 SS won by 10 wickets', 0, '2026-05-28 15:24:27', '2026-05-28 15:24:49'),
(52, 4, 21, 18, 21, 'bat', 18, 21, 2, 8, 0, 2, 0, 11, NULL, 11, 'completed', 21, '🏆 USK won by 2 runs', 0, '2026-05-28 15:25:03', '2026-05-28 15:25:28'),
(53, 5, 19, 22, 22, 'bat', 19, 22, 2, 8, 0, 1, 2, 7, NULL, 33, 'completed', 19, '🏆 HS won by 10 wickets', 0, '2026-05-28 15:25:45', '2026-05-28 15:26:41'),
(54, 6, 19, 20, 19, 'bat', 20, 19, 2, 11, 0, 2, 0, 12, NULL, 18, 'completed', 20, '🏆 RSW won in Super Over', 1, '2026-05-28 17:52:20', '2026-05-28 18:12:25'),
(55, 7, 20, 22, 22, 'field', 22, 20, 2, 13, 0, 2, 1, 12, NULL, 37, 'completed', 22, '🏆 SS won by 10 wickets', 0, '2026-05-28 18:37:04', '2026-05-28 18:38:25'),
(56, 8, 19, 20, 19, 'bat', 20, 19, 2, 10, 0, 2, 0, 11, NULL, 13, 'completed', 19, '🏆 HS won in Super Over', 1, '2026-05-29 16:51:36', '2026-05-29 16:52:44'),
(57, 9, 18, 22, 18, 'bat', 22, 18, 2, 7, 1, 2, 1, 11, NULL, 27, 'completed', 18, '🏆 DF won by 3 runs', 0, '2026-05-30 10:11:27', '2026-05-30 10:13:03'),
(58, 10, 16, 22, 16, 'bat', 16, 22, 1, 17, 2, 5, 1, NULL, NULL, 16281, 'completed', 22, '🏆 SS won the match', 1, '2026-05-30 10:17:10', '2026-05-30 14:49:42');

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

--
-- 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
(76, 49, 1, 17, 18, 10, 0, 2, 0, NULL, '2026-05-28 20:52:46', '2026-05-28 20:53:04', 0, 'completed', '2026-05-28 15:20:38', '2026-05-28 15:23:04'),
(77, 49, 2, 18, 17, 12, 0, 2, 0, 11, '2026-05-28 20:53:11', '2026-05-28 20:53:16', 0, 'completed', '2026-05-28 15:23:11', '2026-05-28 15:23:16'),
(78, 50, 1, 19, 16, 4, 1, 2, 0, NULL, '2026-05-28 20:53:39', '2026-05-28 20:53:56', 0, 'completed', '2026-05-28 15:23:33', '2026-05-28 15:23:56'),
(79, 50, 2, 16, 19, 5, 0, 2, 0, 5, '2026-05-28 20:54:01', '2026-05-28 20:54:08', 0, 'completed', '2026-05-28 15:24:01', '2026-05-28 15:24:08'),
(80, 51, 1, 20, 22, 7, 0, 2, 0, NULL, '2026-05-28 20:54:31', '2026-05-28 20:54:36', 0, 'completed', '2026-05-28 15:24:27', '2026-05-28 15:24:36'),
(81, 51, 2, 22, 20, 9, 0, 2, 0, 8, '2026-05-28 20:54:44', '2026-05-28 20:54:49', 0, 'completed', '2026-05-28 15:24:44', '2026-05-28 15:24:49'),
(82, 52, 1, 21, 18, 10, 0, 2, 0, NULL, '2026-05-28 20:55:06', '2026-05-28 20:55:14', 0, 'completed', '2026-05-28 15:25:03', '2026-05-28 15:25:14'),
(83, 52, 2, 18, 21, 8, 0, 2, 0, 11, '2026-05-28 20:55:17', '2026-05-28 20:55:28', 0, 'completed', '2026-05-28 15:25:17', '2026-05-28 15:25:28'),
(84, 53, 1, 22, 19, 6, 1, 2, 0, NULL, '2026-05-28 20:55:47', '2026-05-28 20:56:01', 0, 'completed', '2026-05-28 15:25:45', '2026-05-28 15:26:01'),
(85, 53, 2, 19, 22, 8, 0, 1, 2, 7, '2026-05-28 20:56:08', '2026-05-28 20:56:41', 0, 'completed', '2026-05-28 15:26:08', '2026-05-28 15:26:41'),
(86, 54, 1, 19, 20, 11, 0, 2, 1, NULL, '2026-05-28 23:22:29', '2026-05-28 23:22:46', 0, 'completed', '2026-05-28 17:52:20', '2026-05-28 17:52:46'),
(87, 54, 2, 20, 19, 11, 0, 2, 0, 12, '2026-05-28 23:41:40', '2026-05-28 23:41:58', 0, 'completed', '2026-05-28 18:11:40', '2026-05-28 18:11:58'),
(88, 55, 1, 20, 22, 11, 0, 2, 1, NULL, '2026-05-29 00:07:11', '2026-05-29 00:07:42', 0, 'completed', '2026-05-28 18:37:04', '2026-05-28 18:37:42'),
(89, 55, 2, 22, 20, 13, 0, 2, 1, 12, '2026-05-29 00:07:48', '2026-05-29 00:08:25', 0, 'completed', '2026-05-28 18:37:48', '2026-05-28 18:38:25'),
(90, 56, 1, 19, 20, 10, 0, 2, 0, NULL, '2026-05-29 22:21:46', '2026-05-29 22:22:03', 0, 'completed', '2026-05-29 16:51:36', '2026-05-29 16:52:03'),
(91, 56, 2, 20, 19, 10, 0, 2, 0, 11, '2026-05-29 22:22:14', '2026-05-29 22:22:27', 0, 'completed', '2026-05-29 16:52:14', '2026-05-29 16:52:27'),
(92, 57, 1, 18, 22, 10, 0, 2, 0, NULL, '2026-05-30 15:41:36', '2026-05-30 15:42:29', 0, 'completed', '2026-05-30 10:11:27', '2026-05-30 10:12:29'),
(93, 57, 2, 22, 18, 7, 1, 2, 1, 11, '2026-05-30 15:42:36', '2026-05-30 15:43:03', 0, 'completed', '2026-05-30 10:12:36', '2026-05-30 10:13:03'),
(94, 58, 1, 16, 22, 17, 2, 5, 1, NULL, '2026-05-30 16:28:13', '2026-05-30 20:19:42', 2392, 'completed', '2026-05-30 10:17:11', '2026-05-30 14:49:42');

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

--
-- 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, 2, 1, 1, 0, 2, 22, 7, 4, 2, '6.857', '2026-05-28 15:18:18', '2026-05-30 14:52:02'),
(7227, 17, 1, 0, 1, 0, 0, 10, 2, 12, 2, '-6.000', '2026-05-28 15:18:30', '2026-05-30 14:52:02'),
(7231, 18, 3, 2, 1, 0, 4, 30, 6, 27, 6, '3.000', '2026-05-28 15:18:41', '2026-05-30 14:52:02'),
(7235, 19, 4, 2, 2, 0, 4, 33, 7, 32, 8, '4.286', '2026-05-28 15:18:53', '2026-05-30 14:52:02'),
(7239, 20, 4, 1, 3, 0, 2, 39, 8, 43, 8, '-3.000', '2026-05-28 15:19:01', '2026-05-30 14:52:02'),
(7243, 21, 1, 1, 0, 0, 2, 10, 2, 8, 2, '6.000', '2026-05-28 15:19:09', '2026-05-30 14:51:57'),
(7246, 22, 5, 3, 2, 0, 6, 35, 8, 53, 12, '-0.250', '2026-05-28 15:19:18', '2026-05-30 14:52:02');

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

--
-- 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');

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

--
-- 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, 'Prasannapura Premier League', 11, 1, 6, 1, 'scoreboard', NULL, NULL, '2026-05-24 13:11:16', '2026-05-30 14:50:07');

--
-- 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=528;

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

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

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

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

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