-- liquibase formatted sql
-- changeset 2fi:20260430_01_create_logistic
-- preconditions onFail:MARK_RAN
-- precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'logistic'

CREATE TABLE `logistic`
(
    `id`           INT          NOT NULL AUTO_INCREMENT,
    `created`      DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `createdBy`    VARCHAR(30)  NULL     DEFAULT NULL,
    `version`      INT          NOT NULL DEFAULT '0',
    `modified`     DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `modifiedBy`   VARCHAR(30)  NULL     DEFAULT NULL,
    `deleted`      TINYINT(1)   NOT NULL DEFAULT '0',
    `logisticName` VARCHAR(255) NOT NULL,
    `carPlate`     VARCHAR(50)  NOT NULL,
    `driverName`   VARCHAR(255) NOT NULL,
    `driverNumber` INT          NOT NULL,
    CONSTRAINT pk_logistic PRIMARY KEY (`id`)
);

-- changeset 2fi:20260430_02_truck_district_reference_to_string
-- preconditions onFail:MARK_RAN
-- precondition-sql-check expectedResult:0 SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'truck' AND column_name = 'districtReference' AND data_type = 'varchar' AND character_maximum_length = 255

ALTER TABLE `truck`
    MODIFY COLUMN `districtReference` VARCHAR(255) NULL;
