/*
  Warnings:

  - You are about to drop the column `dark_mode` on the `preferences` table. All the data in the column will be lost.
  - You are about to drop the column `employee_list_display` on the `preferences` table. All the data in the column will be lost.
  - You are about to drop the column `lang_switch` on the `preferences` table. All the data in the column will be lost.
  - You are about to drop the column `lefty_mode` on the `preferences` table. All the data in the column will be lost.
  - You are about to drop the column `timesheet_display` on the `preferences` table. All the data in the column will be lost.
  - You are about to drop the column `validation_display` on the `preferences` table. All the data in the column will be lost.
  - The `notifications` column on the `preferences` table would be dropped and recreated. This will lead to data loss if there is data in the column.

*/
-- AlterTable
ALTER TABLE "preferences" DROP COLUMN "dark_mode",
DROP COLUMN "employee_list_display",
DROP COLUMN "lang_switch",
DROP COLUMN "lefty_mode",
DROP COLUMN "timesheet_display",
DROP COLUMN "validation_display",
ADD COLUMN     "display_language" TEXT NOT NULL DEFAULT 'fr-FR',
ADD COLUMN     "is_dark_mode" BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN     "is_employee_list_grid" BOOLEAN NOT NULL DEFAULT true,
ADD COLUMN     "is_lefty_mode" BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN     "is_timesheet_approval_grid" BOOLEAN NOT NULL DEFAULT true,
DROP COLUMN "notifications",
ADD COLUMN     "notifications" BOOLEAN NOT NULL DEFAULT true;

-- CreateTable
CREATE TABLE "user_module_access" (
    "id" SERIAL NOT NULL,
    "user_id" UUID NOT NULL,
    "timesheets" BOOLEAN NOT NULL DEFAULT false,
    "timesheets_approval" BOOLEAN NOT NULL DEFAULT false,
    "employee_list" BOOLEAN NOT NULL DEFAULT false,
    "employee_management" BOOLEAN NOT NULL DEFAULT false,
    "personal_profile" BOOLEAN NOT NULL DEFAULT false,
    "dashboard" BOOLEAN NOT NULL DEFAULT false,

    CONSTRAINT "user_module_access_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "user_module_access_user_id_key" ON "user_module_access"("user_id");

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