--liquibase formatted sql

--changeset fpsms:item_lot_trace_log
--preconditions onFail:MARK_RAN
--precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'item_lot_trace_log'
--comment: One row per successful item lot trace (who, what, when)
CREATE TABLE `item_lot_trace_log` (
  `id` bigint 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',
  `userId` bigint NOT NULL,
  `username` varchar(64) NOT NULL,
  `inventoryLotId` bigint DEFAULT NULL,
  `lotNo` varchar(64) DEFAULT NULL,
  `itemId` bigint DEFAULT NULL,
  `itemCode` varchar(64) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_item_lot_trace_log_user_created` (`userId`, `created`),
  KEY `idx_item_lot_trace_log_lot_created` (`inventoryLotId`, `created`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
