-- MySQL Script generated by MySQL Workbench
-- 01/15/17 12:21:36
-- Model: New Model    Version: 1.0
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema vizon
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema vizon
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `vizon` DEFAULT CHARACTER SET latin1 ;
USE `vizon` ;

-- -----------------------------------------------------
-- Table `vizon`.`vizon_users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `vizon`.`vizon_users` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `nick` VARCHAR(64) NOT NULL,
  `vhost` VARCHAR(64) NULL,
  `eligible` TINYINT(1) NULL DEFAULT 0,
  `bold` TINYINT(1) NULL DEFAULT 0,
  `expires` INT NULL DEFAULT -1,
  `obtained` TIMESTAMP NULL,
  `multiplier` INT NULL DEFAULT 1,
  `jackpot` TINYINT(1) NULL DEFAULT 0,
  `permanent` TINYINT(1) NULL DEFAULT 0,
  `days` INT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `nick_UNIQUE` (`nick` ASC))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `vizon`.`vizon_drawings`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `vizon`.`vizon_drawings` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `first` INT NULL,
  `second` INT NULL,
  `third` INT NULL,
  `fourth` INT NULL,
  `fifth` INT NULL,
  `sixth` INT NULL,
  `drawing_date` TIMESTAMP NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `vizon`.`vizon_bets`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `vizon`.`vizon_bets` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `vizon_users_id` INT NOT NULL,
  `vizon_drawings_id` INT NOT NULL,
  `first` INT NOT NULL,
  `second` INT NOT NULL,
  `third` INT NOT NULL,
  `fourth` INT NOT NULL,
  `fifth` INT NOT NULL,
  `sixth` INT NOT NULL,
  `placed` TIMESTAMP NOT NULL DEFAULT NOW(),
  PRIMARY KEY (`id`),
  INDEX `fk_vizon_bets_vizon_users_idx` (`vizon_users_id` ASC),
  INDEX `fk_vizon_bets_vizon_drawings1_idx` (`vizon_drawings_id` ASC),
  CONSTRAINT `fk_vizon_bets_vizon_users`
    FOREIGN KEY (`vizon_users_id`)
    REFERENCES `vizon`.`vizon_users` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_vizon_bets_vizon_drawings1`
    FOREIGN KEY (`vizon_drawings_id`)
    REFERENCES `vizon`.`vizon_drawings` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
