-- Create saved_places table for storing frequently used sender/receiver addresses
CREATE TABLE IF NOT EXISTS `saved_places` (
    `id`            INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
    `label`         VARCHAR(150) NOT NULL COMMENT 'Friendly name for this saved place',
    `place_type`    ENUM('sender','receiver','both') NOT NULL DEFAULT 'both' COMMENT 'Which party this place is used for',
    `company_name`  VARCHAR(150) DEFAULT NULL,
    `contact_name`  VARCHAR(100) DEFAULT NULL,
    `phone`         VARCHAR(30)  DEFAULT NULL,
    `mobile`        VARCHAR(30)  DEFAULT NULL,
    `email`         VARCHAR(150) DEFAULT NULL,
    `address`       VARCHAR(255) DEFAULT NULL,
    `address_2`     VARCHAR(255) DEFAULT NULL,
    `city`          VARCHAR(100) DEFAULT NULL,
    `state`         VARCHAR(100) DEFAULT NULL,
    `country`       VARCHAR(100) DEFAULT 'INDIA',
    `pincode`       VARCHAR(20)  DEFAULT NULL,
    `iec_no`        VARCHAR(50)  DEFAULT NULL,
    `document_type` VARCHAR(80)  DEFAULT NULL,
    `document_no`   VARCHAR(80)  DEFAULT NULL,
    `created_by`    INT(11) DEFAULT 0,
    `status`        ENUM('active','inactive') NOT NULL DEFAULT 'active',
    `created_at`    DATETIME DEFAULT CURRENT_TIMESTAMP,
    `updated_at`    DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    INDEX `idx_status` (`status`),
    INDEX `idx_place_type` (`place_type`),
    INDEX `idx_label` (`label`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Saved sender/receiver addresses for quick reuse in shipment booking';
