/*
  Warnings:

  - You are about to drop the column `user_building_utility_id` on the `User_Building_Details` table. All the data in the column will be lost.
  - You are about to drop the column `user_commodity_id` on the `User_Building_Details` table. All the data in the column will be lost.
  - You are about to drop the `User_Building_Commodities` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `User_Building_Utility` table. If the table is not empty, all the data it contains will be lost.
  - Added the required column `user_building_commodity_utility_id` to the `User_Building_Details` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE `User_Building_Commodities` DROP FOREIGN KEY `User_Building_Commodities_commodity_id_fkey`;

-- DropForeignKey
ALTER TABLE `User_Building_Commodities` DROP FOREIGN KEY `User_Building_Commodities_user_building_details_id_fkey`;

-- DropForeignKey
ALTER TABLE `User_Building_Details` DROP FOREIGN KEY `User_Building_Details_user_building_utility_id_fkey`;

-- DropForeignKey
ALTER TABLE `User_Building_Utility` DROP FOREIGN KEY `User_Building_Utility_commodity_id_fkey`;

-- DropForeignKey
ALTER TABLE `User_Building_Utility` DROP FOREIGN KEY `User_Building_Utility_utility_id_fkey`;

-- AlterTable
ALTER TABLE `User_Building_Details` DROP COLUMN `user_building_utility_id`,
    DROP COLUMN `user_commodity_id`,
    ADD COLUMN `user_building_commodity_utility_id` VARCHAR(191) NOT NULL;

-- DropTable
DROP TABLE `User_Building_Commodities`;

-- DropTable
DROP TABLE `User_Building_Utility`;

-- CreateTable
CREATE TABLE `User_Building_Commodity_Utitlity` (
    `user_building_utility_id` VARCHAR(191) NOT NULL,
    `utility_name` VARCHAR(191) NOT NULL,
    `streetAddress` VARCHAR(191) NOT NULL,
    `accountNumber` VARCHAR(191) NOT NULL,
    `unit` VARCHAR(191) NOT NULL,
    `city` VARCHAR(191) NOT NULL,
    `postalCode` VARCHAR(191) NOT NULL,
    `numberOfOccupants` VARCHAR(191) NOT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,
    `utility_id` VARCHAR(191) NOT NULL,
    `commodity_id` VARCHAR(191) NOT NULL,
    `user_building_detail_id` VARCHAR(191) NOT NULL,

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

-- AddForeignKey
ALTER TABLE `User_Building_Commodity_Utitlity` ADD CONSTRAINT `User_Building_Commodity_Utitlity_utility_id_fkey` FOREIGN KEY (`utility_id`) REFERENCES `Utility_Companies`(`utility_company_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `User_Building_Commodity_Utitlity` ADD CONSTRAINT `User_Building_Commodity_Utitlity_commodity_id_fkey` FOREIGN KEY (`commodity_id`) REFERENCES `Commodity`(`commodity_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `User_Building_Commodity_Utitlity` ADD CONSTRAINT `User_Building_Commodity_Utitlity_user_building_detail_id_fkey` FOREIGN KEY (`user_building_detail_id`) REFERENCES `User_Building_Details`(`user_building_details_id`) ON DELETE CASCADE ON UPDATE CASCADE;
