QwikClock is an employee time tracking app.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

152 lines
4.8 KiB

-- MySQL Script generated by MySQL Workbench
-- Wed 30 May 2018 07:09:00 PM MDT
-- 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 qwikclock
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `qwikclock` ;
-- -----------------------------------------------------
-- Schema qwikclock
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `qwikclock` DEFAULT CHARACTER SET utf8 ;
USE `qwikclock` ;
-- -----------------------------------------------------
-- Table `qwikclock`.`shifts`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `qwikclock`.`shifts` ;
CREATE TABLE IF NOT EXISTS `qwikclock`.`shifts` (
`shiftid` INT NOT NULL AUTO_INCREMENT,
`shiftname` VARCHAR(255) NOT NULL,
`start` TIME NOT NULL,
`end` TIME NOT NULL,
`days` VARCHAR(14) NOT NULL DEFAULT 'MoTuWeThFr',
PRIMARY KEY (`shiftid`),
UNIQUE INDEX `shiftid_UNIQUE` (`shiftid` ASC))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `qwikclock`.`punches`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `qwikclock`.`punches` ;
CREATE TABLE IF NOT EXISTS `qwikclock`.`punches` (
`punchid` INT NOT NULL AUTO_INCREMENT,
`uid` INT NOT NULL,
`in` DATETIME NOT NULL,
`out` DATETIME NULL,
`notes` TEXT(1000) NULL,
`shiftid` INT NULL,
PRIMARY KEY (`punchid`),
UNIQUE INDEX `punchid_UNIQUE` (`punchid` ASC),
INDEX `fk_punches_shifts1_idx` (`shiftid` ASC),
CONSTRAINT `fk_punches_shifts1`
FOREIGN KEY (`shiftid`)
REFERENCES `qwikclock`.`shifts` (`shiftid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `qwikclock`.`assigned_shifts`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `qwikclock`.`assigned_shifts` ;
CREATE TABLE IF NOT EXISTS `qwikclock`.`assigned_shifts` (
`uid` INT NOT NULL,
`shiftid` INT NOT NULL,
PRIMARY KEY (`uid`, `shiftid`),
INDEX `fk_assigned_shifts_shifts_idx` (`shiftid` ASC),
CONSTRAINT `fk_assigned_shifts_shifts`
FOREIGN KEY (`shiftid`)
REFERENCES `qwikclock`.`shifts` (`shiftid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `qwikclock`.`report_access_codes`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `qwikclock`.`report_access_codes` ;
CREATE TABLE IF NOT EXISTS `qwikclock`.`report_access_codes` (
`id` INT NOT NULL AUTO_INCREMENT,
`code` VARCHAR(45) NULL,
`expires` DATETIME NULL,
`uid` INT NOT NULL DEFAULT -1,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `qwikclock`.`jobs`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `qwikclock`.`jobs` ;
CREATE TABLE IF NOT EXISTS `qwikclock`.`jobs` (
`jobid` INT NOT NULL AUTO_INCREMENT,
`jobname` VARCHAR(200) NOT NULL,
`jobcode` VARCHAR(200) NULL,
`color` VARCHAR(45) NULL,
`deleted` TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`jobid`),
UNIQUE INDEX `jobid_UNIQUE` (`jobid` ASC))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `qwikclock`.`job_groups`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `qwikclock`.`job_groups` ;
CREATE TABLE IF NOT EXISTS `qwikclock`.`job_groups` (
`id` INT NOT NULL AUTO_INCREMENT,
`groupid` INT NOT NULL,
`jobid` INT NOT NULL,
PRIMARY KEY (`id`, `groupid`, `jobid`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
INDEX `fk_job_groups_jobs1_idx` (`jobid` ASC),
CONSTRAINT `fk_job_groups_jobs1`
FOREIGN KEY (`jobid`)
REFERENCES `qwikclock`.`jobs` (`jobid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `qwikclock`.`job_tracking`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `qwikclock`.`job_tracking` ;
CREATE TABLE IF NOT EXISTS `qwikclock`.`job_tracking` (
`id` INT NOT NULL AUTO_INCREMENT,
`uid` INT NOT NULL,
`jobid` INT NOT NULL,
`start` DATETIME NULL,
`end` DATETIME NULL,
PRIMARY KEY (`id`, `uid`, `jobid`),
INDEX `fk_job_tracking_jobs1_idx` (`jobid` ASC),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
CONSTRAINT `fk_job_tracking_jobs1`
FOREIGN KEY (`jobid`)
REFERENCES `qwikclock`.`jobs` (`jobid`)
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;