--liquibase formatted sql
--changeset jason_lam:create production_schedule table
CREATE TABLE production_schedule
(
    id          INT            NOT NULL AUTO_INCREMENT,
    version     INT            NOT NULL DEFAULT '0',
    created     datetime       NOT NULL DEFAULT CURRENT_TIMESTAMP,
    createdBy   VARCHAR(30) NULL,
    modified    datetime       NOT NULL DEFAULT CURRENT_TIMESTAMP,
    modifiedBy  VARCHAR(30) NULL,
    deleted     TINYINT(1) NOT NULL DEFAULT '0',

    scheduleAt          datetime         NOT NULL DEFAULT CURRENT_TIMESTAMP,
    totalEstProdCount   DECIMAL(16, 2)   NULL,
    totalFGType         INT(11)          NULL,
    CONSTRAINT pk_production_schedule PRIMARY KEY (id)
);

CREATE TABLE production_schedule_line
(
    id          INT            NOT NULL AUTO_INCREMENT,
    version     INT            NOT NULL DEFAULT '0',
    created     datetime       NOT NULL DEFAULT CURRENT_TIMESTAMP,
    createdBy   VARCHAR(30) NULL,
    modified    datetime       NOT NULL DEFAULT CURRENT_TIMESTAMP,
    modifiedBy  VARCHAR(30) NULL,
    deleted     TINYINT(1) NOT NULL DEFAULT '0',

    prodScheduleId      INT(11)           NOT NULL,
    itemId              INT(11)           NOT NULL,
    lastMonthAvgSales   DECIMAL(16, 2)    NULL DEFAULT 0.0,
    prodQty             DECIMAL(16, 2)    NOT NULL,
    estCloseBal         DECIMAL(16, 2)    NULL DEFAULT 0.0,
    type                VARCHAR(30)       NOT NULL DEFAULT "rough",
    approverId          INT(11)           NULL,
    refScheduleId       INT(11)           NULL,
    CONSTRAINT pk_production_schedule_line PRIMARY KEY (id)
);