/*
  Warnings:

  - You are about to drop the column `end_date_time` on the `leave_requests` table. All the data in the column will be lost.
  - You are about to drop the column `start_date_time` on the `leave_requests` table. All the data in the column will be lost.
  - You are about to drop the column `end_date_time` on the `leave_requests_archive` table. All the data in the column will be lost.
  - You are about to drop the column `start_date_time` on the `leave_requests_archive` table. All the data in the column will be lost.
  - A unique constraint covering the columns `[employee_id,leave_type,date]` on the table `leave_requests` will be added. If there are existing duplicate values, this will fail.
  - A unique constraint covering the columns `[leave_request_id]` on the table `leave_requests_archive` will be added. If there are existing duplicate values, this will fail.
  - Added the required column `date` to the `leave_requests` table without a default value. This is not possible if the table is not empty.
  - Added the required column `date` to the `leave_requests_archive` table without a default value. This is not possible if the table is not empty.

*/
-- AlterEnum
ALTER TYPE "leave_types" ADD VALUE 'HOLIDAY';

-- AlterTable
ALTER TABLE "leave_requests" DROP COLUMN "end_date_time",
DROP COLUMN "start_date_time",
ADD COLUMN     "date" DATE NOT NULL,
ADD COLUMN     "payable_hours" DECIMAL(5,2),
ADD COLUMN     "requested_hours" DECIMAL(5,2);

-- AlterTable
ALTER TABLE "leave_requests_archive" DROP COLUMN "end_date_time",
DROP COLUMN "start_date_time",
ADD COLUMN     "date" DATE NOT NULL,
ADD COLUMN     "payable_hours" DECIMAL(5,2),
ADD COLUMN     "requested_hours" DECIMAL(5,2);

-- CreateTable
CREATE TABLE "preferences" (
    "user_id" UUID NOT NULL,
    "notifications" BOOLEAN NOT NULL DEFAULT false,
    "dark_mode" BOOLEAN NOT NULL DEFAULT false,
    "lang_switch" BOOLEAN NOT NULL DEFAULT false,
    "lefty_mode" BOOLEAN NOT NULL DEFAULT false
);

-- CreateIndex
CREATE UNIQUE INDEX "preferences_user_id_key" ON "preferences"("user_id");

-- CreateIndex
CREATE INDEX "leave_requests_employee_id_date_idx" ON "leave_requests"("employee_id", "date");

-- CreateIndex
CREATE UNIQUE INDEX "leave_requests_employee_id_leave_type_date_key" ON "leave_requests"("employee_id", "leave_type", "date");

-- CreateIndex
CREATE INDEX "leave_requests_archive_employee_id_date_idx" ON "leave_requests_archive"("employee_id", "date");

-- CreateIndex
CREATE UNIQUE INDEX "leave_requests_archive_leave_request_id_key" ON "leave_requests_archive"("leave_request_id");

-- AddForeignKey
ALTER TABLE "preferences" ADD CONSTRAINT "preferences_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
