-- MySQL Script generated by MySQL Workbench
-- Sat Apr  4 20:03:35 2020
-- 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 exksc
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema exksc
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `exksc` DEFAULT CHARACTER SET utf8 ;
USE `exksc` ;

-- -----------------------------------------------------
-- Table `exksc`.`machine_id`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`machine_id` (
  `id` BIGINT(20) NOT NULL,
  `machine_id` VARCHAR(32) NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`wp_user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`wp_user` (
  `id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`machine_id_has_wp_user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`machine_id_has_wp_user` (
  `machine_id_id` BIGINT(20) NOT NULL,
  `wp_user_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`machine_id_id`, `wp_user_id`),
  INDEX `fk_machine_id_has_wp_user_wp_user1_idx` (`wp_user_id` ASC),
  INDEX `fk_machine_id_has_wp_user_machine_id1_idx` (`machine_id_id` ASC),
  CONSTRAINT `fk_machine_id_has_wp_user_machine_id1`
    FOREIGN KEY (`machine_id_id`)
    REFERENCES `exksc`.`machine_id` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_machine_id_has_wp_user_wp_user1`
    FOREIGN KEY (`wp_user_id`)
    REFERENCES `exksc`.`wp_user` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`page`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`page` (
  `id` BIGINT(20) NOT NULL,
  `uri` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`page_view`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`page_view` (
  `id` BIGINT(20) NOT NULL,
  `page_id` BIGINT(20) NOT NULL,
  `query` VARCHAR(255) NOT NULL,
  `ip` VARCHAR(29) NOT NULL,
  `timestamp` DATETIME NOT NULL,
  `duration` INT NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_page_view_page1_idx` (`page_id` ASC),
  CONSTRAINT `fk_page_view_page1`
    FOREIGN KEY (`page_id`)
    REFERENCES `exksc`.`page` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`video`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`video` (
  `id` BIGINT(20) NOT NULL,
  `file_id` VARCHAR(255) NOT NULL,
  `video_id` VARCHAR(255) NOT NULL,
  `title` VARCHAR(255) NULL,
  `duration` INT NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`video_view`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`video_view` (
  `id` BIGINT(20) NOT NULL,
  `video_id` BIGINT(20) NOT NULL,
  `completed` TINYINT(1) NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_video_view_video1_idx` (`video_id` ASC),
  CONSTRAINT `fk_video_view_video1`
    FOREIGN KEY (`video_id`)
    REFERENCES `exksc`.`video` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`video_event`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`video_event` (
  `id` BIGINT(20) NOT NULL,
  `type` VARCHAR(45) NOT NULL,
  `time` BIGINT(20) NOT NULL,
  `timestamp` DATETIME NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`machine_id_has_page_view`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`machine_id_has_page_view` (
  `machine_id_id` BIGINT(20) NOT NULL,
  `page_view_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`machine_id_id`, `page_view_id`),
  INDEX `fk_machine_id_has_page_view_page_view1_idx` (`page_view_id` ASC),
  INDEX `fk_machine_id_has_page_view_machine_id1_idx` (`machine_id_id` ASC),
  CONSTRAINT `fk_machine_id_has_page_view_machine_id1`
    FOREIGN KEY (`machine_id_id`)
    REFERENCES `exksc`.`machine_id` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_machine_id_has_page_view_page_view1`
    FOREIGN KEY (`page_view_id`)
    REFERENCES `exksc`.`page_view` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`machine_id_has_video_view`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`machine_id_has_video_view` (
  `machine_id_id` INT NOT NULL,
  `video_view_id` INT NOT NULL,
  PRIMARY KEY (`machine_id_id`, `video_view_id`),
  INDEX `fk_machine_id_has_video_view_video_view1_idx` (`video_view_id` ASC),
  INDEX `fk_machine_id_has_video_view_machine_id1_idx` (`machine_id_id` ASC),
  CONSTRAINT `fk_machine_id_has_video_view_machine_id1`
    FOREIGN KEY (`machine_id_id`)
    REFERENCES `exksc`.`machine_id` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_machine_id_has_video_view_video_view1`
    FOREIGN KEY (`video_view_id`)
    REFERENCES `exksc`.`video_view` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`page_has_video`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`page_has_video` (
  `page_id` BIGINT(20) NOT NULL,
  `video_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`page_id`, `video_id`),
  INDEX `fk_page_has_video_video1_idx` (`video_id` ASC),
  INDEX `fk_page_has_video_page1_idx` (`page_id` ASC),
  CONSTRAINT `fk_page_has_video_page1`
    FOREIGN KEY (`page_id`)
    REFERENCES `exksc`.`page` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_page_has_video_video1`
    FOREIGN KEY (`video_id`)
    REFERENCES `exksc`.`video` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`video_view_has_video_event`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`video_view_has_video_event` (
  `video_view_id` BIGINT(20) NOT NULL,
  `video_event_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`video_view_id`, `video_event_id`),
  INDEX `fk_video_view_has_video_event_video_event1_idx` (`video_event_id` ASC),
  INDEX `fk_video_view_has_video_event_video_view1_idx` (`video_view_id` ASC),
  CONSTRAINT `fk_video_view_has_video_event_video_view1`
    FOREIGN KEY (`video_view_id`)
    REFERENCES `exksc`.`video_view` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_video_view_has_video_event_video_event1`
    FOREIGN KEY (`video_event_id`)
    REFERENCES `exksc`.`video_event` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`robots`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`robots` (
  `user_agent` VARCHAR(191) NOT NULL,
  `robots_txt` DATETIME NOT NULL,
  `hit` DATETIME NOT NULL,
  PRIMARY KEY (`user_agent`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`cmd`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`cmd` (
  `id` BIGINT(20) NOT NULL,
  `timestamp` DATETIME NOT NULL,
  `query` VARCHAR(255) NOT NULL,
  `uri` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`machine_id_has_cmd`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`machine_id_has_cmd` (
  `machine_id_id` BIGINT(20) NOT NULL,
  `cmd_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`machine_id_id`, `cmd_id`),
  INDEX `fk_machine_id_has_cmd_cmd1_idx` (`cmd_id` ASC),
  INDEX `fk_machine_id_has_cmd_machine_id1_idx` (`machine_id_id` ASC),
  CONSTRAINT `fk_machine_id_has_cmd_machine_id1`
    FOREIGN KEY (`machine_id_id`)
    REFERENCES `exksc`.`machine_id` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_machine_id_has_cmd_cmd1`
    FOREIGN KEY (`cmd_id`)
    REFERENCES `exksc`.`cmd` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`page_view_has_video_view`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`page_view_has_video_view` (
  `page_view_id` BIGINT(20) NOT NULL,
  `video_view_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`page_view_id`, `video_view_id`),
  INDEX `fk_page_view_has_video_view_video_view1_idx` (`video_view_id` ASC),
  INDEX `fk_page_view_has_video_view_page_view1_idx` (`page_view_id` ASC),
  CONSTRAINT `fk_page_view_has_video_view_page_view1`
    FOREIGN KEY (`page_view_id`)
    REFERENCES `exksc`.`page_view` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_page_view_has_video_view_video_view1`
    FOREIGN KEY (`video_view_id`)
    REFERENCES `exksc`.`video_view` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`order`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`order` (
  `id` BIGINT(20) NOT NULL,
  `token` VARCHAR(32) NOT NULL,
  `timestamp` DATETIME NOT NULL,
  `ip` VARCHAR(29) NOT NULL,
  PRIMARY KEY (`id`, `token`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`client`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`client` (
  `id` BIGINT(20) NOT NULL,
  `first` VARCHAR(128) NOT NULL,
  `last` VARCHAR(128) NOT NULL,
  `company` VARCHAR(128) NOT NULL,
  `email` VARCHAR(128) NOT NULL,
  `address1` VARCHAR(256) NOT NULL,
  `address2` VARCHAR(256) NOT NULL,
  `city` VARCHAR(128) NOT NULL,
  `state` VARCHAR(45) NOT NULL,
  `zip` VARCHAR(10) NOT NULL,
  `country` VARCHAR(128) NOT NULL,
  `phone1` VARCHAR(45) NOT NULL,
  `phone2` VARCHAR(45) NOT NULL,
  `fax` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`order_has_client`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`order_has_client` (
  `order_id` BIGINT(20) NOT NULL,
  `client_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`order_id`, `client_id`),
  INDEX `fk_order_has_client_client1_idx` (`client_id` ASC),
  INDEX `fk_order_has_client_order1_idx` (`order_id` ASC),
  CONSTRAINT `fk_order_has_client_order1`
    FOREIGN KEY (`order_id`)
    REFERENCES `exksc`.`order` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_order_has_client_client1`
    FOREIGN KEY (`client_id`)
    REFERENCES `exksc`.`client` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`product`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`product` (
  `id` BIGINT(20) NOT NULL,
  `name` VARCHAR(128) NOT NULL,
  `price` VARCHAR(9) NOT NULL,
  `sku` VARCHAR(10) NOT NULL,
  `shortDesc` VARCHAR(250) NOT NULL,
  `longDesc` VARCHAR(4096) NOT NULL,
  `image` VARCHAR(256) NOT NULL,
  `pid` VARCHAR(32) NOT NULL,
  `removed` TINYINT(1) NOT NULL,
  `hosted` INT NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`item`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`item` (
  `id` BIGINT(20) NOT NULL,
  `product_id` BIGINT(20) NOT NULL,
  `recurring` TINYINT(1) NOT NULL,
  `quantity` INT NOT NULL,
  `price` VARCHAR(9) NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_item_product1_idx` (`product_id` ASC),
  CONSTRAINT `fk_item_product1`
    FOREIGN KEY (`product_id`)
    REFERENCES `exksc`.`product` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`order_has_item`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`order_has_item` (
  `order_id` BIGINT(20) NOT NULL,
  `item_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`order_id`, `item_id`),
  INDEX `fk_order_has_item_item1_idx` (`item_id` ASC),
  INDEX `fk_order_has_item_order1_idx` (`order_id` ASC),
  CONSTRAINT `fk_order_has_item_order1`
    FOREIGN KEY (`order_id`)
    REFERENCES `exksc`.`order` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_order_has_item_item1`
    FOREIGN KEY (`item_id`)
    REFERENCES `exksc`.`item` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`machine_id_has_order`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`machine_id_has_order` (
  `machine_id_id` INT NOT NULL,
  `order_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`machine_id_id`, `order_id`),
  INDEX `fk_machine_id_has_order_order1_idx` (`order_id` ASC),
  INDEX `fk_machine_id_has_order_machine_id1_idx` (`machine_id_id` ASC),
  CONSTRAINT `fk_machine_id_has_order_machine_id1`
    FOREIGN KEY (`machine_id_id`)
    REFERENCES `exksc`.`machine_id` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_machine_id_has_order_order1`
    FOREIGN KEY (`order_id`)
    REFERENCES `exksc`.`order` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`notify`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`notify` (
  `id` BIGINT(20) NOT NULL,
  `content` VARCHAR(1024) NOT NULL,
  `timestamp` DATETIME NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`shipping`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`shipping` (
  `id` BIGINT(20) NOT NULL,
  `name` VARCHAR(256) NOT NULL,
  `address1` VARCHAR(256) NOT NULL,
  `address2` VARCHAR(256) NOT NULL,
  `city` VARCHAR(128) NOT NULL,
  `state` VARCHAR(45) NOT NULL,
  `zip` VARCHAR(10) NOT NULL,
  `country` VARCHAR(128) NOT NULL,
  `residential` TINYINT(1) NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`order_has_shipping`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`order_has_shipping` (
  `order_id` BIGINT(20) NOT NULL,
  `shipping_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`order_id`, `shipping_id`),
  INDEX `fk_order_has_shipping_shipping1_idx` (`shipping_id` ASC),
  INDEX `fk_order_has_shipping_order1_idx` (`order_id` ASC),
  CONSTRAINT `fk_order_has_shipping_order1`
    FOREIGN KEY (`order_id`)
    REFERENCES `exksc`.`order` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_order_has_shipping_shipping1`
    FOREIGN KEY (`shipping_id`)
    REFERENCES `exksc`.`shipping` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`member`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`member` (
  `client_id` BIGINT(20) NOT NULL,
  INDEX `fk_member_client1_idx` (`client_id` ASC),
  PRIMARY KEY (`client_id`),
  CONSTRAINT `fk_member_client1`
    FOREIGN KEY (`client_id`)
    REFERENCES `exksc`.`client` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`client_has_product`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`client_has_product` (
  `client_id` BIGINT(20) NOT NULL,
  `product_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`client_id`, `product_id`),
  INDEX `fk_client_has_product1_product1_idx` (`product_id` ASC),
  INDEX `fk_client_has_product1_client1_idx` (`client_id` ASC),
  CONSTRAINT `fk_client_has_product1_client1`
    FOREIGN KEY (`client_id`)
    REFERENCES `exksc`.`client` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_client_has_product1_product1`
    FOREIGN KEY (`product_id`)
    REFERENCES `exksc`.`product` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`client_has_product`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`client_has_product` (
  `client_id` BIGINT(20) NOT NULL,
  `product_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`client_id`, `product_id`),
  INDEX `fk_client_has_product1_product1_idx` (`product_id` ASC),
  INDEX `fk_client_has_product1_client1_idx` (`client_id` ASC),
  CONSTRAINT `fk_client_has_product1_client1`
    FOREIGN KEY (`client_id`)
    REFERENCES `exksc`.`client` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_client_has_product1_product1`
    FOREIGN KEY (`product_id`)
    REFERENCES `exksc`.`product` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`host`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`host` (
  `id` BIGINT(20) NOT NULL,
  `number` INT NOT NULL,
  `name` VARCHAR(256) NOT NULL,
  PRIMARY KEY (`id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`user` (
  `id` BIGINT(20) NOT NULL,
  `email` VARCHAR(128) NOT NULL,
  `host_id` BIGINT(20) NOT NULL,
  `wp_user_id` BIGINT(20) NOT NULL,
  `password` VARCHAR(128) NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_user_host1_idx` (`host_id` ASC),
  CONSTRAINT `fk_user_host1`
    FOREIGN KEY (`host_id`)
    REFERENCES `exksc`.`host` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`member_has_user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`member_has_user` (
  `member_client_id` BIGINT(20) NOT NULL,
  `user_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`member_client_id`, `user_id`),
  INDEX `fk_member_has_user_user1_idx` (`user_id` ASC),
  INDEX `fk_member_has_user_member1_idx` (`member_client_id` ASC),
  CONSTRAINT `fk_member_has_user_member1`
    FOREIGN KEY (`member_client_id`)
    REFERENCES `exksc`.`member` (`client_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_member_has_user_user1`
    FOREIGN KEY (`user_id`)
    REFERENCES `exksc`.`user` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `exksc`.`client_has_user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `exksc`.`client_has_user` (
  `client_id` BIGINT(20) NOT NULL,
  `user_id` BIGINT(20) NOT NULL,
  PRIMARY KEY (`client_id`, `user_id`),
  INDEX `fk_client_has_user_user1_idx` (`user_id` ASC),
  INDEX `fk_client_has_user_client1_idx` (`client_id` ASC),
  CONSTRAINT `fk_client_has_user_client1`
    FOREIGN KEY (`client_id`)
    REFERENCES `exksc`.`client` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_client_has_user_user1`
    FOREIGN KEY (`user_id`)
    REFERENCES `exksc`.`user` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


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