/*
  Warnings:

  - You are about to drop the `Building_Level_Appliances` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `R_Other_Appliances` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `Room_Other_Appliances` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE `Room_Other_Appliances` DROP FOREIGN KEY `Room_Other_Appliances_other_appliance_id_fkey`;

-- DropTable
DROP TABLE `Building_Level_Appliances`;

-- DropTable
DROP TABLE `R_Other_Appliances`;

-- DropTable
DROP TABLE `Room_Other_Appliances`;

-- CreateTable
CREATE TABLE `User_Room_Other_Appliances` (
    `room_other_appliance_id` VARCHAR(191) NOT NULL,
    `appliance_name` VARCHAR(191) NOT NULL,
    `sensibleHeat` VARCHAR(191) NOT NULL,
    `latentHeat` VARCHAR(191) NOT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,
    `other_appliance_id` VARCHAR(191) NOT NULL,

    PRIMARY KEY (`room_other_appliance_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `User_Building_Other_Appliances` (
    `user_building_oa_id` VARCHAR(191) NOT NULL,
    `sensibleHeat` VARCHAR(191) NULL,
    `latentHeat` VARCHAR(191) NULL,
    `user_building_id` VARCHAR(191) NOT NULL,
    `building_lvl_other_app_id` VARCHAR(191) NOT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    PRIMARY KEY (`user_building_oa_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Building_Level_Other_Appliances` (
    `building_lvl_other_app_id` VARCHAR(191) NOT NULL,
    `appliance_name` VARCHAR(191) NOT NULL,
    `sensibleHeat` VARCHAR(191) NOT NULL,
    `latentHeat` VARCHAR(191) NOT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `Building_Level_Other_Appliances_appliance_name_key`(`appliance_name`),
    PRIMARY KEY (`building_lvl_other_app_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `User_Building_EV_Charger_Model` (
    `user_building_ev_charger_model_id` VARCHAR(191) NOT NULL,
    `sensibleHeat` VARCHAR(191) NULL,
    `latentHeat` VARCHAR(191) NULL,
    `ev_model_id` VARCHAR(191) NOT NULL,
    `user_building_id` VARCHAR(191) NOT NULL,

    PRIMARY KEY (`user_building_ev_charger_model_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Building_Ev_Charger_Model` (
    `building_ev_charger_model_id` VARCHAR(191) NOT NULL,
    `name` VARCHAR(191) NOT NULL,
    `sensibleHeat` VARCHAR(191) NULL,
    `latentHeat` VARCHAR(191) NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `Building_Ev_Charger_Model_name_key`(`name`),
    PRIMARY KEY (`building_ev_charger_model_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `Room_Level_Other_Appliances` (
    `other_appliances_id` VARCHAR(191) NOT NULL,
    `appliance_name` VARCHAR(191) NOT NULL,
    `sensibleHeat` VARCHAR(191) NOT NULL,
    `latentHeat` VARCHAR(191) NOT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `Room_Level_Other_Appliances_appliance_name_key`(`appliance_name`),
    PRIMARY KEY (`other_appliances_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `User_Room_Other_Appliances` ADD CONSTRAINT `User_Room_Other_Appliances_other_appliance_id_fkey` FOREIGN KEY (`other_appliance_id`) REFERENCES `Room_Level_Other_Appliances`(`other_appliances_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `User_Building_Other_Appliances` ADD CONSTRAINT `User_Building_Other_Appliances_user_building_id_fkey` FOREIGN KEY (`user_building_id`) REFERENCES `User_Building_Details`(`user_building_details_id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `User_Building_Other_Appliances` ADD CONSTRAINT `User_Building_Other_Appliances_building_lvl_other_app_id_fkey` FOREIGN KEY (`building_lvl_other_app_id`) REFERENCES `Building_Level_Other_Appliances`(`building_lvl_other_app_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `User_Building_EV_Charger_Model` ADD CONSTRAINT `User_Building_EV_Charger_Model_ev_model_id_fkey` FOREIGN KEY (`ev_model_id`) REFERENCES `Building_Ev_Charger_Model`(`building_ev_charger_model_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `User_Building_EV_Charger_Model` ADD CONSTRAINT `User_Building_EV_Charger_Model_user_building_id_fkey` FOREIGN KEY (`user_building_id`) REFERENCES `User_Building_Details`(`user_building_details_id`) ON DELETE CASCADE ON UPDATE CASCADE;
