-- phpMyAdmin SQL Dump
-- version 4.1.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: May 19, 2015 at 12:50 AM
-- Server version: 5.6.15-log
-- PHP Version: 5.5.6

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

--
-- Database: `buckovidlib`
--

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

--
-- Table structure for table `actors`
--

DROP TABLE IF EXISTS `actors`;
CREATE TABLE `actors` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(64) NOT NULL,
  `plexId` int(11) NOT NULL,
  `thumb` varchar(100) DEFAULT NULL COMMENT 'url',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `directors`
--

DROP TABLE IF EXISTS `directors`;
CREATE TABLE `directors` (
  `directorId` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(128) NOT NULL,
  PRIMARY KEY (`directorId`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `genres`
--

DROP TABLE IF EXISTS `genres`;
CREATE TABLE `genres` (
  `genreId` int(11) NOT NULL AUTO_INCREMENT,
  `tag` varchar(128) NOT NULL,
  PRIMARY KEY (`genreId`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `librarysections`
--

DROP TABLE IF EXISTS `librarysections`;
CREATE TABLE `librarysections` (
  `id` int(11) NOT NULL,
  `name` varchar(64) NOT NULL,
  `ctype` char(2) NOT NULL,
  `restricted` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `misc_failedtorip`
--

DROP TABLE IF EXISTS `misc_failedtorip`;
CREATE TABLE `misc_failedtorip` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(64) NOT NULL,
  `comment` varchar(256) NOT NULL,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `misc_wishlist`
--

DROP TABLE IF EXISTS `misc_wishlist`;
CREATE TABLE `misc_wishlist` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(64) NOT NULL,
  `year` smallint(6) NOT NULL,
  `comment` varchar(256) NOT NULL,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `tvseasons`
--

DROP TABLE IF EXISTS `tvseasons`;
CREATE TABLE `tvseasons` (
  `seasonId` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(64) NOT NULL,
  `plexKey` int(11) NOT NULL,
  `addedAt` bigint(20) NOT NULL,
  `updatedAt` bigint(20) NOT NULL,
  `episodeCount` int(11) DEFAULT NULL,
  `videoId` int(11) NOT NULL,
  `hashKey` int(11) NOT NULL,
  PRIMARY KEY (`seasonId`),
  UNIQUE KEY `HashKey` (`hashKey`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `users`
--

DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `userId` int(11) NOT NULL,
  `attkey` varchar(16) NOT NULL,
  `value` varchar(32) NOT NULL,
  UNIQUE KEY `userId` (`userId`,`attkey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `videos`
--

DROP TABLE IF EXISTS `videos`;
CREATE TABLE `videos` (
  `videoId` int(11) NOT NULL AUTO_INCREMENT,
  `ctype` char(2) NOT NULL DEFAULT 'V',
  `hashKey` int(11) NOT NULL,
  `section` smallint(5) unsigned NOT NULL,
  `title` varchar(64) NOT NULL,
  `year` int(11) NOT NULL,
  `plexKey` int(11) NOT NULL,
  `studio` varchar(40) DEFAULT NULL,
  `addedAt` bigint(20) NOT NULL,
  `updatedAt` bigint(20) NOT NULL,
  `duration` int(11) NOT NULL COMMENT 'no of seconds',
  `sortIndex` int(11) NOT NULL COMMENT 'The order this video is sorted in the LibrarySection',
  `sortTitle` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`videoId`),
  UNIQUE KEY `plexKey` (`plexKey`),
  UNIQUE KEY `hashKey` (`hashKey`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `videotexts`
--

DROP TABLE IF EXISTS `videotexts`;
CREATE TABLE `videotexts` (
  `videoId` int(11) NOT NULL,
  `tagline` varchar(256) DEFAULT NULL,
  `summary` varchar(3072) DEFAULT NULL,
  UNIQUE KEY `videoId` (`videoId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `video_actors`
--

DROP TABLE IF EXISTS `video_actors`;
CREATE TABLE `video_actors` (
  `videoId` int(11) NOT NULL,
  `actorId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='map actors to movies';

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

--
-- Table structure for table `video_directors`
--

DROP TABLE IF EXISTS `video_directors`;
CREATE TABLE `video_directors` (
  `videoId` int(11) NOT NULL,
  `directorId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `video_genres`
--

DROP TABLE IF EXISTS `video_genres`;
CREATE TABLE `video_genres` (
  `videoId` int(11) NOT NULL,
  `genreId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `video_writers`
--

DROP TABLE IF EXISTS `video_writers`;
CREATE TABLE `video_writers` (
  `videoId` int(11) NOT NULL,
  `writerId` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Table structure for table `writers`
--

DROP TABLE IF EXISTS `writers`;
CREATE TABLE `writers` (
  `writerId` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(128) NOT NULL,
  UNIQUE KEY `id` (`writerId`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

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