--liquibase formatted sql
--changeset fai:20260311_m18_cunit

CREATE TABLE `m18_cunit` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `version` int NOT NULL DEFAULT '0',
  `created` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  `createdBy` varchar(30) DEFAULT NULL,
  `modified` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  `modifiedBy` varchar(30) DEFAULT NULL,
  `deleted` tinyint(1) NOT NULL DEFAULT '0',
  `m18Id` bigint NOT NULL COMMENT 'M18 unit id (parent unit from read/unit)',
  `m18CunitLineId` bigint NOT NULL COMMENT 'M18 cunit row id',
  `ratioN` decimal(20, 10) DEFAULT NULL COMMENT 'Stored from M18 ratioD (swapped)',
  `ratioD` decimal(20, 10) DEFAULT NULL COMMENT 'Stored from M18 ratioN (swapped)',
  `hId` bigint DEFAULT NULL,
  `unitId` bigint DEFAULT NULL,
  `iRev` int DEFAULT NULL,
  `itemNo` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_m18_cunit_line` (`m18CunitLineId`),
  KEY `idx_m18_cunit_m18Id` (`m18Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
