
ALTER TABLE `{{TABLE_PREFIX}}_voter_house` ADD `ward_name` TEXT NULL AFTER `ward`;


CREATE TABLE IF NOT EXISTS `{{TABLE_PREFIX}}_voter_house_animal_details` (
  `id` int NOT NULL AUTO_INCREMENT,
  `house_id` int NOT NULL,
  `animal` text NOT NULL,
  `count` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `house_id` (`house_id`)
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


ALTER TABLE `{{TABLE_PREFIX}}_voter_house_animal_details`
  ADD CONSTRAINT `{{TABLE_PREFIX}}_voter_house_animal_details_ibfk_1` FOREIGN KEY (`house_id`) REFERENCES `{{TABLE_PREFIX}}_voter_house` (`id`) ON DELETE CASCADE;



CREATE TABLE IF NOT EXISTS `{{TABLE_PREFIX}}_voter_house_agricultural_table` (
  `id` int NOT NULL AUTO_INCREMENT,
  `house_id` int NOT NULL,
  `crop_type` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `area` varchar(50) DEFAULT NULL,
  `remark` text,
  PRIMARY KEY (`id`),
  KEY `house_id` (`house_id`)
) ENGINE=InnoDB AUTO_INCREMENT=47 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

ALTER TABLE `{{TABLE_PREFIX}}_voter_house_agricultural_table`
  ADD CONSTRAINT `{{TABLE_PREFIX}}_voter_house_agricultural_table_ibfk_1` FOREIGN KEY (`house_id`) REFERENCES `{{TABLE_PREFIX}}_voter_house` (`id`) ON DELETE CASCADE;


CREATE TABLE IF NOT EXISTS `{{TABLE_PREFIX}}_voter_house_vehicle_table` (
  `id` int NOT NULL AUTO_INCREMENT,
  `house_id` int NOT NULL,
  `vehicle_type` text NOT NULL,
  `count` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `house_id` (`house_id`)
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


ALTER TABLE `{{TABLE_PREFIX}}_voter_house_vehicle_table`
  ADD CONSTRAINT `{{TABLE_PREFIX}}_voter_house_vehicle_table_ibfk_1` FOREIGN KEY (`house_id`) REFERENCES `{{TABLE_PREFIX}}_voter_house` (`id`) ON DELETE CASCADE;


CREATE TABLE IF NOT EXISTS `{{TABLE_PREFIX}}_voter_house_nearby_resources` (
  `id` int NOT NULL AUTO_INCREMENT,
  `house_id` int NOT NULL,
  `resource_type` text NOT NULL,
  `distance` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `house_id` (`house_id`)
) ENGINE=InnoDB AUTO_INCREMENT=106 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

ALTER TABLE `{{TABLE_PREFIX}}_voter_house_nearby_resources`
  ADD CONSTRAINT `{{TABLE_PREFIX}}_voter_house_nearby_resources_ibfk_1` FOREIGN KEY (`house_id`) REFERENCES `{{TABLE_PREFIX}}_voter_house` (`id`) ON DELETE CASCADE;

