-- phpMyAdmin SQL Dump
-- version 5.1.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Sep 14, 2024 at 04:09 AM
-- Server version: 10.6.18-MariaDB-0ubuntu0.22.04.1-log
-- PHP Version: 8.1.2-1ubuntu2.18

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: `matchdb`
--

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

--
-- Table structure for table `antStatus`
--

CREATE TABLE `antStatus` (
  `streamId` varchar(255) NOT NULL,
  `cage` int(11) NOT NULL DEFAULT 0,
  `cageOverride` varchar(32) DEFAULT NULL,
  `updateTime` bigint(20) NOT NULL DEFAULT 0,
  `publishType` varchar(64) NOT NULL,
  `status` varchar(64) NOT NULL,
  `viewers` int(11) NOT NULL DEFAULT 0,
  `recording` int(11) NOT NULL DEFAULT 0,
  `recordingStart` bigint(20) NOT NULL DEFAULT 0,
  `recordingEvent` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `credentials`
--

CREATE TABLE `credentials` (
  `userID` varchar(255) NOT NULL,
  `apiKey` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `games`
--

CREATE TABLE `games` (
  `id` varchar(255) NOT NULL,
  `tournamentID` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `round` int(11) NOT NULL,
  `scoreToWin` int(11) NOT NULL,
  `state` varchar(64) NOT NULL,
  `calledSince` bigint(20) DEFAULT NULL,
  `availableSince` bigint(20) DEFAULT NULL,
  `endTime` bigint(20) DEFAULT NULL,
  `winAnnotation` varchar(255) DEFAULT NULL,
  `loserPlacement` int(11) DEFAULT NULL,
  `locationID` varchar(255) DEFAULT NULL,
  `startTime` bigint(20) NOT NULL DEFAULT 0,
  `stopTime` bigint(20) NOT NULL DEFAULT 0,
  `countdown` int(11) NOT NULL DEFAULT 0,
  `duration` int(11) NOT NULL DEFAULT 0,
  `paused` int(11) NOT NULL DEFAULT 0,
  `judgesString` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `locationPriority`
--

CREATE TABLE `locationPriority` (
  `tournamentID` varchar(128) NOT NULL,
  `locationName` varchar(64) NOT NULL,
  `priority` int(11) NOT NULL DEFAULT 100,
  `locationLock` tinyint(4) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `locations`
--

CREATE TABLE `locations` (
  `id` varchar(255) NOT NULL,
  `tournamentID` varchar(64) DEFAULT NULL,
  `name` varchar(64) DEFAULT NULL,
  `activeGameID` varchar(255) DEFAULT NULL,
  `lastCompletedGameID` varchar(255) DEFAULT NULL,
  `queue` text DEFAULT NULL,
  `unavailableQueue` text DEFAULT NULL,
  `status` varchar(64) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `players`
--

CREATE TABLE `players` (
  `id` varchar(255) NOT NULL,
  `tournamentID` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `cleanName` varchar(64) NOT NULL,
  `seed` int(11) NOT NULL,
  `wins` int(11) NOT NULL,
  `losses` int(11) NOT NULL,
  `isBye` tinyint(4) NOT NULL,
  `isDisqualified` int(11) NOT NULL,
  `lastPlayTime` bigint(20) NOT NULL,
  `mostRecentGameID` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `recordings`
--

CREATE TABLE `recordings` (
  `recordingID` int(11) NOT NULL,
  `gameID` varchar(255) NOT NULL,
  `tournamentID` varchar(255) DEFAULT NULL,
  `cage` varchar(64) NOT NULL,
  `red` varchar(128) NOT NULL,
  `blue` varchar(128) NOT NULL,
  `result` varchar(64) NOT NULL,
  `matchStart` int(11) NOT NULL,
  `camera` varchar(128) NOT NULL,
  `antID` varchar(255) NOT NULL,
  `s3path` varchar(255) DEFAULT NULL,
  `s3http` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `rounds`
--

CREATE TABLE `rounds` (
  `tournamentID` varchar(64) NOT NULL,
  `round` int(11) NOT NULL,
  `roundName` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `slots`
--

CREATE TABLE `slots` (
  `gameID` varchar(255) NOT NULL,
  `tournamentID` varchar(255) NOT NULL,
  `slotIdx` int(11) NOT NULL,
  `playerID` varchar(255) DEFAULT NULL,
  `prevGameID` varchar(255) DEFAULT NULL,
  `score` varchar(32) DEFAULT NULL,
  `isWinner` tinyint(1) DEFAULT NULL,
  `isReady` int(11) NOT NULL DEFAULT 0,
  `unstickTime` int(11) NOT NULL DEFAULT 0,
  `showMotionTime` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `streams`
--

CREATE TABLE `streams` (
  `streamID` int(11) NOT NULL,
  `location` varchar(64) NOT NULL,
  `camera` varchar(64) NOT NULL,
  `streamURL` varchar(1024) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `tournaments`
--

CREATE TABLE `tournaments` (
  `tournamentID` varchar(64) NOT NULL,
  `tournamentName` varchar(64) DEFAULT NULL,
  `createTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `scheduledStartTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `startTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `endTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `updateTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `numPlayers` int(11) NOT NULL DEFAULT 0,
  `WeightClass` int(11) NOT NULL,
  `active` tinyint(4) NOT NULL DEFAULT 0,
  `isTest` tinyint(4) NOT NULL DEFAULT 0,
  `isFreestyle` tinyint(4) NOT NULL DEFAULT 0,
  `privacy` varchar(64) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `antStatus`
--
ALTER TABLE `antStatus`
  ADD PRIMARY KEY (`streamId`);

--
-- Indexes for table `credentials`
--
ALTER TABLE `credentials`
  ADD PRIMARY KEY (`userID`);

--
-- Indexes for table `games`
--
ALTER TABLE `games`
  ADD PRIMARY KEY (`id`,`tournamentID`),
  ADD KEY `name` (`name`);

--
-- Indexes for table `locationPriority`
--
ALTER TABLE `locationPriority`
  ADD PRIMARY KEY (`tournamentID`,`locationName`);

--
-- Indexes for table `locations`
--
ALTER TABLE `locations`
  ADD PRIMARY KEY (`id`),
  ADD KEY `name` (`name`),
  ADD KEY `tournamentID` (`tournamentID`),
  ADD KEY `activeGameID` (`activeGameID`);

--
-- Indexes for table `players`
--
ALTER TABLE `players`
  ADD PRIMARY KEY (`id`),
  ADD KEY `cleanName` (`cleanName`),
  ADD KEY `name` (`name`),
  ADD KEY `tournamentID` (`tournamentID`);

--
-- Indexes for table `recordings`
--
ALTER TABLE `recordings`
  ADD PRIMARY KEY (`recordingID`),
  ADD KEY `antID` (`antID`),
  ADD KEY `gameID` (`gameID`),
  ADD KEY `tournamentID` (`tournamentID`);

--
-- Indexes for table `rounds`
--
ALTER TABLE `rounds`
  ADD PRIMARY KEY (`tournamentID`,`round`);

--
-- Indexes for table `slots`
--
ALTER TABLE `slots`
  ADD PRIMARY KEY (`gameID`,`tournamentID`,`slotIdx`),
  ADD KEY `playerID` (`playerID`);

--
-- Indexes for table `streams`
--
ALTER TABLE `streams`
  ADD PRIMARY KEY (`streamID`);

--
-- Indexes for table `tournaments`
--
ALTER TABLE `tournaments`
  ADD PRIMARY KEY (`tournamentID`),
  ADD KEY `active` (`active`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `recordings`
--
ALTER TABLE `recordings`
  MODIFY `recordingID` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `streams`
--
ALTER TABLE `streams`
  MODIFY `streamID` int(11) NOT NULL AUTO_INCREMENT;
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 */;
