-- 007_user_shipping_addresses.sql

-- ====================================
-- 19. USER_SHIPPING_ADDRESSES TABLE
-- ====================================
CREATE TABLE IF NOT EXISTS user_shipping_addresses (
    id BIGINT PRIMARY KEY AUTO_INCREMENT,
    address_id VARCHAR(100) UNIQUE NOT NULL,
    user_id VARCHAR(100) NOT NULL,
    full_name VARCHAR(255) NOT NULL,
    phone_number VARCHAR(20) NOT NULL,
    village VARCHAR(100) NOT NULL,
    union_name VARCHAR(100) NOT NULL,
    full_address TEXT NOT NULL,
    is_default BOOLEAN DEFAULT FALSE,
    location_type VARCHAR(50) DEFAULT 'Home', -- 'Home', 'Office', etc.
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    
    INDEX idx_user_id (user_id),
    FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
