-- CreateTable
CREATE TABLE "parent-job" (
    "id" BIGSERIAL NOT NULL,
    "title" VARCHAR(150) NOT NULL,
    "address" VARCHAR(250) NOT NULL,
    "phone" VARCHAR(15) NOT NULL,
    "skill_id" BIGINT,
    "parent_id" BIGINT NOT NULL,
    "is_active" BOOLEAN NOT NULL DEFAULT true,
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3) NOT NULL,
    "deactivated_at" TIMESTAMP(3),
    "deactivated_by_id" BIGINT,

    CONSTRAINT "parent-job_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "parent-job_parent_id_idx" ON "parent-job"("parent_id");

-- CreateIndex
CREATE INDEX "parent-job_skill_id_idx" ON "parent-job"("skill_id");

-- AddForeignKey
ALTER TABLE "parent-job" ADD CONSTRAINT "parent-job_skill_id_fkey" FOREIGN KEY ("skill_id") REFERENCES "skills"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "parent-job" ADD CONSTRAINT "parent-job_parent_id_fkey" FOREIGN KEY ("parent_id") REFERENCES "parents"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "parent-job" ADD CONSTRAINT "parent-job_deactivated_by_id_fkey" FOREIGN KEY ("deactivated_by_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
