-- CreateTable
CREATE TABLE "parents" (
    "id" BIGSERIAL NOT NULL,
    "fullname" VARCHAR(100) NOT NULL,
    "mobile" VARCHAR(20) NOT NULL,
    "nationalCode" VARCHAR(10) NOT NULL,
    "password" VARCHAR(100) NOT NULL,
    "relationStudent" "ParentStudentRelation" NOT NULL DEFAULT 'FATHER',
    "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 "parents_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "parents_mobile_key" ON "parents"("mobile");

-- CreateIndex
CREATE UNIQUE INDEX "parents_nationalCode_key" ON "parents"("nationalCode");

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