/*
SQLyog Ultimate v12.5.1 (64 bit)
MySQL - 10.4.6-MariaDB : Database - gts
*********************************************************************
*/

/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`gts` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `gts`;

/*Table structure for table `dc` */

DROP TABLE IF EXISTS `dc`;

CREATE TABLE `dc` (
  `dc_no` varchar(15) NOT NULL,
  `dc_date` date NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=37461 DEFAULT CHARSET=utf8;

/*Table structure for table `m_buyer` */

DROP TABLE IF EXISTS `m_buyer`;

CREATE TABLE `m_buyer` (
  `unit_id` varchar(10) NOT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_at` datetime(6) NOT NULL DEFAULT current_timestamp(6),
  `updated_at` datetime(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `buyer_name` varchar(100) NOT NULL,
  `buyer_code` varchar(100) NOT NULL,
  `line_desc` text DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=latin1;

/*Table structure for table `m_operation` */

DROP TABLE IF EXISTS `m_operation`;

CREATE TABLE `m_operation` (
  `unit_id` varchar(10) NOT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_at` datetime(6) NOT NULL DEFAULT current_timestamp(6),
  `updated_at` datetime(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ext_ref_code` varchar(6) NOT NULL,
  `op_code` varchar(6) NOT NULL,
  `op_name` varchar(30) NOT NULL,
  `op_category` varchar(1) NOT NULL,
  `op_sequence` smallint(6) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=latin1;

/*Table structure for table `m_po_header` */

DROP TABLE IF EXISTS `m_po_header`;

CREATE TABLE `m_po_header` (
  `unit_id` varchar(10) NOT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_at` datetime(6) NOT NULL DEFAULT current_timestamp(6),
  `updated_at` datetime(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `buyer_id` mediumint(9) NOT NULL,
  `po_number` varchar(30) NOT NULL,
  `po_description` varchar(30) NOT NULL,
  `po_id` varchar(30) NOT NULL,
  `po_name` varchar(40) NOT NULL,
  `po_status` varchar(20) NOT NULL,
  `product_id` varchar(20) NOT NULL,
  `product_type` varchar(30) NOT NULL,
  `productDesc` varchar(30) NOT NULL,
  `style` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1342 DEFAULT CHARSET=latin1;

/*Table structure for table `m_po_line` */

DROP TABLE IF EXISTS `m_po_line`;

CREATE TABLE `m_po_line` (
  `unit_id` varchar(10) NOT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_at` datetime(6) NOT NULL DEFAULT current_timestamp(6),
  `updated_at` datetime(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `po_header_id` mediumint(9) NOT NULL,
  `style` varchar(30) NOT NULL,
  `color` varchar(30) NOT NULL,
  `destination` varchar(60) NOT NULL,
  `delivery_date` datetime NOT NULL,
  `po_status` varchar(10) NOT NULL,
  `quantity` mediumint(9) NOT NULL default 0,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4535 DEFAULT CHARSET=latin1;

/*Table structure for table `m_schedule` */

DROP TABLE IF EXISTS `m_schedule`;

CREATE TABLE `m_schedule` (
  `unit_id` varchar(10) NOT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_at` datetime(6) NOT NULL DEFAULT current_timestamp(6),
  `updated_at` datetime(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `po_header_id` mediumint(9) NOT NULL,
  `po_line_id` mediumint(9) NOT NULL,
  `style` varchar(30) NOT NULL,
  `color` varchar(30) NOT NULL,
  `schedule` varchar(15) NOT NULL,
  `quantity` mediumint(9) NOT NULL default 0,
  `destination` varchar(60) NOT NULL,
  `delivery_date` datetime NOT NULL,
  `po_status` varchar(10) NOT NULL,
  `start_date` varchar(10) NOT NULL,
  `end_date` varchar(10) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4534 DEFAULT CHARSET=latin1;

/*Table structure for table `m_style_operation` */

DROP TABLE IF EXISTS `m_style_operation`;

CREATE TABLE `m_style_operation` (
  `unit_id` varchar(10) NOT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_at` datetime(6) NOT NULL DEFAULT current_timestamp(6),
  `updated_at` datetime(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `style` varchar(30) NOT NULL,
  `op_code` varchar(6) NOT NULL,
  `op_category` varchar(1) NOT NULL,
  `op_sequence` smallint(6) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1891 DEFAULT CHARSET=latin1;

/*Table structure for table `t_tracking_info` */

DROP TABLE IF EXISTS `t_tracking_info`;

CREATE TABLE `t_tracking_info` (
  `unit_id` varchar(10) NOT NULL,
  `is_active` tinyint(4) NOT NULL DEFAULT 1,
  `created_at` datetime(6) NOT NULL DEFAULT current_timestamp(6),
  `updated_at` datetime(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `po_header_id` mediumint(9) NOT NULL,
  `po_schedule_id` mediumint(9) NOT NULL,
  `schedule` varchar(15) NOT NULL,
  `style` varchar(30) NOT NULL,
  `color` varchar(30) NOT NULL,
  `year` smallint(6) NOT NULL,
  `month` tinyint(4) NOT NULL,
  `hour` tinyint(4) NOT NULL,
  `minute` tinyint(4) NOT NULL,
  `good_quantity` mediumint(9) NOT NULL,
  `date` varchar(10) NOT NULL,
  `ref_type` varchar(10) NOT NULL,
  `ref_id` varchar(20) DEFAULT '0',
  `line` varchar(20) NOT NULL DEFAULT '',
  `workstation` varchar(20) NOT NULL DEFAULT '',
  `op_code` varchar(6) NOT NULL,
  `op_category` varchar(1) NOT NULL,
  `op_sequence` tinyint(4) NOT NULL,
  `timestamp` varchar(20) NOT NULL,
  `rework_quantity` mediumint(9) NOT NULL,
  `rejected_quantity` mediumint(9) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=357091 DEFAULT CHARSET=latin1;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;




CREATE TABLE m_schedule_dc (
  id INT AUTO_INCREMENT PRIMARY KEY, 
  po_sch_id INT NOT NULL, 
  po_header_id INT NOT NULL, 
  dc_no VARCHAR(20) NOT NULL,
  quantity int default 0,
  unit_id VARCHAR(10) NOT NULL,
  is_active TINYINT(4) NOT NULL DEFAULT 1,
  created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  updated_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)
);

