targo-backend/prisma/migrations/20260106124750_added_paid_time_off/migration.sql

37 lines
1.4 KiB
SQL

/*
Warnings:
- You are about to drop the column `sort_order` on the `schedule_preset_shifts` table. All the data in the column will be lost.
- A unique constraint covering the columns `[preset_id,week_day]` on the table `schedule_preset_shifts` will be added. If there are existing duplicate values, this will fail.
- Added the required column `daily_expected_hours` to the `employees` table without a default value. This is not possible if the table is not empty.
*/
-- DropIndex
DROP INDEX "public"."schedule_preset_shifts_preset_id_week_day_sort_order_key";
-- AlterTable
ALTER TABLE "employees" ADD COLUMN "daily_expected_hours" INTEGER NOT NULL;
-- AlterTable
ALTER TABLE "schedule_preset_shifts" DROP COLUMN "sort_order";
-- CreateTable
CREATE TABLE "paid_time_off" (
"id" SERIAL NOT NULL,
"employee_id" INTEGER NOT NULL,
"vacation_hours" INTEGER NOT NULL DEFAULT 0,
"sick_hours" INTEGER NOT NULL DEFAULT 0,
"last_updated" DATE NOT NULL,
CONSTRAINT "paid_time_off_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "paid_time_off_employee_id_key" ON "paid_time_off"("employee_id");
-- CreateIndex
CREATE UNIQUE INDEX "schedule_preset_shifts_preset_id_week_day_key" ON "schedule_preset_shifts"("preset_id", "week_day");
-- AddForeignKey
ALTER TABLE "paid_time_off" ADD CONSTRAINT "paid_time_off_employee_id_fkey" FOREIGN KEY ("employee_id") REFERENCES "employees"("id") ON DELETE RESTRICT ON UPDATE CASCADE;