-- liquibase formatted sql
-- changeset KelvinY:create_stock_transfer_record_table

CREATE TABLE IF NOT EXISTS `stock_transfer_record` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdBy` VARCHAR(30) DEFAULT NULL,
  `version` INT NOT NULL DEFAULT '0',
  `modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `modifiedBy` VARCHAR(30) DEFAULT NULL,
  `deleted` TINYINT(1) NOT NULL DEFAULT '0',

  `itemId` INT NOT NULL,
  `itemCode` VARCHAR(50),
  `itemName` VARCHAR(200),
  `lotNo` VARCHAR(512),

  `transferredQty` DECIMAL(14,2) NOT NULL,
  `startLocation` VARCHAR(255),
  `targetLocation` VARCHAR(255),

  `stockInLineId` INT,
  `stockOutLineId` INT,

  PRIMARY KEY (`id`),
  INDEX `idx_stock_transfer_record_itemId` (`itemId`),
  INDEX `idx_stock_transfer_record_stockInLineId` (`stockInLineId`),
  INDEX `idx_stock_transfer_record_stockOutLineId` (`stockOutLineId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;