-- CreateTable
CREATE TABLE "Expenses" (
    "id" SERIAL NOT NULL,
    "timesheet_id" INTEGER NOT NULL,
    "expense_code_id" INTEGER NOT NULL,
    "date" TIMESTAMP(3) NOT NULL,
    "amount" DOUBLE PRECISION NOT NULL,
    "attachement" TEXT,
    "description" TEXT,
    "is_approved" BOOLEAN NOT NULL DEFAULT false,
    "supervisor_comment" TEXT,

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

-- CreateTable
CREATE TABLE "ExpenseCodes" (
    "id" SERIAL NOT NULL,
    "expense_type" TEXT NOT NULL,
    "bank_code" TEXT NOT NULL,

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

-- AddForeignKey
ALTER TABLE "Expenses" ADD CONSTRAINT "Expenses_timesheet_id_fkey" FOREIGN KEY ("timesheet_id") REFERENCES "timesheets"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Expenses" ADD CONSTRAINT "Expenses_expense_code_id_fkey" FOREIGN KEY ("expense_code_id") REFERENCES "ExpenseCodes"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
