-- Migration: Add Property Details and Consignee Setting
-- Suitable for Property Dealer / Real Estate & Dynamic Company Types

-- 1. Update companies table for consignee setting, property details setting, and business type
ALTER TABLE `companies` 
ADD COLUMN IF NOT EXISTS `enable_consignee` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '1 = Consignee enabled, 0 = Consignee disabled',
ADD COLUMN IF NOT EXISTS `enable_property_details` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '1 = Property/Unit Details enabled, 0 = Disabled',
ADD COLUMN IF NOT EXISTS `business_type` VARCHAR(50) DEFAULT 'real_estate' COMMENT 'real_estate, general, services, other';

-- 2. Update sales table for property/service details
ALTER TABLE `sales`
ADD COLUMN IF NOT EXISTS `flat_no` VARCHAR(100) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `tower_block` VARCHAR(100) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `carpet_area` VARCHAR(100) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `agreement_ref` VARCHAR(150) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `property_details` TEXT DEFAULT NULL;

-- 3. Update quotations table for property/service details
ALTER TABLE `quotations`
ADD COLUMN IF NOT EXISTS `flat_no` VARCHAR(100) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `tower_block` VARCHAR(100) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `carpet_area` VARCHAR(100) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `agreement_ref` VARCHAR(150) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `property_details` TEXT DEFAULT NULL;

-- 4. Update challans table for property/service details
ALTER TABLE `challans`
ADD COLUMN IF NOT EXISTS `flat_no` VARCHAR(100) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `tower_block` VARCHAR(100) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `carpet_area` VARCHAR(100) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `agreement_ref` VARCHAR(150) DEFAULT NULL,
ADD COLUMN IF NOT EXISTS `property_details` TEXT DEFAULT NULL;
