-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 27, 2026 at 06:34 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
(677, 76, 1, 0, 1, 2, 2, 0, 'none', 0, 1, '2', '2026-07-07 16:51:57'),
(678, 76, 1, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-07-07 16:52:04'),
(679, 76, 1, 0, 3, 4, 4, 0, 'none', 0, 1, '4', '2026-07-07 16:52:10'),
(680, 76, 1, 0, 4, 0, 0, 0, 'none', 1, 1, 'W', '2026-07-07 16:52:18'),
(681, 76, 1, 0, 5, 0, 0, 0, 'none', 0, 1, '•', '2026-07-07 16:52:26'),
(682, 76, 1, 0, 6, 2, 0, 2, 'wd', 0, 0, 'WD+1', '2026-07-07 16:52:41'),
(683, 76, 1, 0, 6, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-07-07 16:52:45'),
(684, 76, 1, 0, 6, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-07-07 16:52:55'),
(685, 76, 1, 0, 6, 6, 6, 0, 'none', 0, 1, '6', '2026-07-07 16:53:06'),
(686, 76, 2, 0, 1, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-07-07 16:53:23'),
(687, 76, 2, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-07-07 16:53:31'),
(688, 76, 2, 0, 2, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-07-07 16:54:02'),
(689, 76, 2, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-07-07 16:54:10'),
(690, 76, 2, 0, 3, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-07-07 16:54:16'),
(691, 76, 2, 0, 3, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-07-07 16:55:27'),
(692, 77, 1, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-07-10 14:43:55'),
(693, 77, 1, 0, 2, 7, 6, 1, 'nb', 0, 0, 'NB+6', '2026-07-10 14:44:05'),
(694, 77, 1, 0, 2, 2, 2, 0, 'none', 0, 1, '2', '2026-07-10 14:44:19'),
(695, 77, 1, 0, 3, 1, 0, 1, 'wd', 0, 0, 'WD', '2026-07-10 14:46:01'),
(696, 77, 1, 0, 3, 1, 0, 1, 'wd', 0, 0, 'WD', '2026-07-10 14:46:04'),
(697, 77, 1, 0, 3, 0, 0, 0, 'none', 1, 1, 'W', '2026-07-10 14:46:23'),
(698, 77, 1, 0, 4, 6, 6, 0, 'none', 0, 1, '6', '2026-07-10 14:46:33'),
(699, 77, 1, 0, 5, 4, 4, 0, 'none', 0, 1, '4', '2026-07-10 14:46:37'),
(700, 77, 1, 0, 6, 1, 1, 0, 'none', 0, 1, '1', '2026-07-10 14:46:43'),
(701, 77, 2, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-07-10 14:47:46'),
(702, 77, 2, 0, 2, 4, 4, 0, 'none', 0, 1, '4', '2026-07-10 14:47:53'),
(703, 77, 2, 0, 3, 0, 0, 0, 'none', 0, 1, '•', '2026-07-10 14:47:59'),
(704, 77, 2, 0, 4, 7, 6, 1, 'nb', 0, 0, 'NB+6', '2026-07-10 14:48:07'),
(705, 77, 2, 0, 4, 2, 2, 0, 'none', 0, 1, '2', '2026-07-10 14:48:49'),
(706, 77, 2, 0, 5, 5, 5, 0, 'none', 0, 1, '5', '2026-07-10 14:48:53'),
(707, 77, 2, 0, 6, 6, 6, 0, 'none', 0, 1, '6', '2026-07-10 14:49:04'),
(708, 79, 1, 0, 1, 3, 3, 0, 'none', 0, 1, '3', '2026-07-25 10:23:23'),
(709, 79, 1, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-07-25 10:23:32'),
(710, 79, 1, 0, 3, 7, 6, 1, 'nb', 0, 0, 'NB+6', '2026-07-25 10:23:48'),
(711, 79, 1, 0, 3, 0, 0, 0, 'none', 1, 1, 'W', '2026-07-25 10:23:54'),
(712, 79, 1, 0, 4, 4, 4, 0, 'none', 0, 1, '4', '2026-07-25 10:24:02'),
(713, 79, 1, 0, 5, 6, 6, 0, 'none', 0, 1, '6', '2026-07-25 10:27:46'),
(714, 79, 1, 0, 6, 4, 4, 0, 'none', 0, 1, '4', '2026-07-25 10:27:57'),
(715, 79, 2, 0, 1, 3, 3, 0, 'none', 0, 1, '3', '2026-07-25 10:28:53'),
(716, 79, 2, 0, 2, 6, 6, 0, 'none', 0, 1, '6', '2026-07-25 10:29:06'),
(717, 79, 2, 0, 3, 0, 0, 0, 'none', 1, 1, 'W', '2026-07-25 10:29:13'),
(718, 80, 1, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-07-25 12:41:20'),
(719, 80, 1, 0, 2, 0, 0, 0, 'none', 1, 1, 'W', '2026-07-25 12:41:25'),
(720, 80, 1, 0, 3, 4, 4, 0, 'none', 0, 1, '4', '2026-07-25 12:41:28'),
(721, 80, 1, 0, 4, 6, 6, 0, 'none', 0, 1, '6', '2026-07-25 12:43:16'),
(722, 80, 1, 0, 5, 0, 0, 0, 'none', 1, 1, 'W', '2026-07-25 12:43:39'),
(723, 80, 1, 0, 6, 4, 4, 0, 'none', 0, 1, '4', '2026-07-25 12:43:47'),
(724, 80, 2, 0, 1, 6, 6, 0, 'none', 0, 1, '6', '2026-07-27 15:09:42'),
(725, 80, 2, 0, 2, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-07-27 15:09:51'),
(726, 80, 2, 0, 2, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-07-27 15:14:53'),
(729, 80, 2, 0, 2, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-07-27 15:18:11'),
(730, 80, 2, 0, 2, 0, 0, 0, 'none', 1, 1, 'W', '2026-07-27 15:18:13'),
(731, 80, 2, 0, 3, 2, 2, 0, 'none', 0, 1, '2', '2026-07-27 15:18:23'),
(732, 80, 2, 0, 4, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-07-27 15:23:32'),
(733, 80, 2, 0, 4, 0, 0, 0, 'none', 1, 1, 'W', '2026-07-27 15:23:38'),
(735, 80, 2, 0, 5, 6, 6, 0, 'none', 0, 1, '6', '2026-07-27 15:25:39'),
(736, 80, 2, 0, 6, 1, 0, 1, 'nb', 0, 0, 'NB', '2026-07-27 15:25:45'),
(737, 80, 2, 0, 6, 2, 2, 0, 'none', 0, 1, '2', '2026-07-27 15:25:52');

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

--
-- 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
(76, 1, 19, 17, 17, 'bat', 19, 17, 2, 16, 0, 2, 4, 23, NULL, 250971, 'completed', 17, '🏆 GS won the match', 1, '2026-07-07 16:51:36', '2026-07-10 14:36:08'),
(77, 2, 18, 23, 18, 'bat', 23, 18, 2, 30, 0, 6, 1, 29, NULL, 50, 'completed', 23, '🏆 NS won by 10 wickets', 0, '2026-07-10 14:43:30', '2026-07-10 14:49:04'),
(79, 3, 19, 20, 19, 'bat', 20, 19, 2, 9, 1, 3, 0, 31, NULL, 99, 'completed', 19, '🏆 HS won the match', 1, '2026-07-25 10:21:29', '2026-07-25 10:29:40'),
(80, 4, 23, 22, 23, 'bat', 22, 23, 2, 21, 2, 6, 5, 21, NULL, 668, 'completed', 22, '🏆 SS won by 8 wickets', 0, '2026-07-25 12:39:25', '2026-07-27 15:25:53'),
(81, 5, 17, 22, 17, 'bat', 17, 22, 1, 0, 0, 0, 0, NULL, NULL, 31, 'completed', 17, '🏆 GS won the match', 1, '2026-07-27 15:28:07', '2026-07-27 15:29:02'),
(83, 6, 16, 19, 16, 'field', 19, 16, 1, 0, 0, 0, 0, NULL, NULL, 682, 'live', NULL, NULL, 0, '2026-07-27 15:30:10', '2026-07-27 15:47:14');

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

--
-- 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
(119, 76, 1, 17, 19, 22, 1, 6, 4, NULL, NULL, '2026-07-07 22:23:06', 76, 'completed', '2026-07-07 16:51:36', '2026-07-07 16:53:06'),
(120, 76, 2, 19, 17, 16, 0, 2, 4, 23, NULL, '2026-07-10 20:06:08', 250971, 'completed', '2026-07-07 16:53:17', '2026-07-10 14:36:08'),
(121, 77, 1, 18, 23, 28, 1, 6, 3, NULL, NULL, '2026-07-10 20:16:43', 176, 'completed', '2026-07-10 14:43:30', '2026-07-10 14:46:43'),
(122, 77, 2, 23, 18, 30, 0, 6, 1, 29, NULL, '2026-07-10 20:19:04', 50, 'completed', '2026-07-10 14:47:36', '2026-07-10 14:49:04'),
(124, 79, 1, 19, 20, 30, 1, 6, 1, NULL, NULL, '2026-07-25 15:57:57', 293, 'completed', '2026-07-25 10:21:29', '2026-07-25 10:27:57'),
(125, 79, 2, 20, 19, 9, 1, 3, 0, 31, NULL, '2026-07-25 15:59:40', 99, 'completed', '2026-07-25 10:28:01', '2026-07-25 10:29:40'),
(126, 80, 1, 23, 22, 20, 2, 6, 0, NULL, NULL, '2026-07-25 18:13:47', 151, 'completed', '2026-07-25 12:39:25', '2026-07-25 12:43:47'),
(127, 80, 2, 22, 23, 21, 2, 6, 5, 21, NULL, '2026-07-27 20:55:53', 668, 'completed', '2026-07-27 15:09:23', '2026-07-27 15:25:53'),
(128, 81, 1, 17, 22, 0, 0, 0, 0, NULL, NULL, '2026-07-27 20:59:02', 31, 'completed', '2026-07-27 15:28:07', '2026-07-27 15:29:02'),
(130, 83, 1, 19, 16, 0, 0, 0, 0, NULL, NULL, NULL, 682, 'live', '2026-07-27 15:30:10', '2026-07-27 15:47:14');

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

--
-- 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-28 15:18:18', '2026-07-07 16:50:14'),
(7227, 17, 2, 2, 0, 0, 4, 22, 6, 16, 2, '-26.000', '2026-05-28 15:18:30', '2026-07-27 15:42:09'),
(7231, 18, 1, 0, 1, 0, 0, 28, 6, 30, 6, '-2.000', '2026-05-28 15:18:41', '2026-07-27 15:42:09'),
(7235, 19, 2, 1, 1, 0, 2, 46, 8, 31, 9, '13.833', '2026-05-28 15:18:53', '2026-07-27 15:42:09'),
(7239, 20, 1, 0, 1, 0, 0, 9, 3, 30, 6, '-12.000', '2026-05-28 15:19:01', '2026-07-27 15:42:09'),
(7243, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0.000', '2026-05-28 15:19:09', '2026-06-09 16:43:41'),
(7246, 22, 2, 1, 1, 0, 2, 21, 6, 20, 6, '1.000', '2026-05-28 15:19:18', '2026-07-27 15:42:09'),
(11697, 23, 2, 1, 1, 0, 2, 50, 12, 49, 12, '0.500', '2026-07-03 14:45:31', '2026-07-27 15:42:09');

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

--
-- 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-07-27 15:42:08');

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

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

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

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

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