-- AlterTable
ALTER TABLE "Admin" ADD COLUMN IF NOT EXISTS "createdByAdminId" TEXT;

-- CreateIndex
CREATE INDEX IF NOT EXISTS "Admin_createdByAdminId_idx" ON "Admin"("createdByAdminId");

-- AddForeignKey
DO $$
BEGIN
    IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'Admin_createdByAdminId_fkey') THEN
        ALTER TABLE "Admin"
        ADD CONSTRAINT "Admin_createdByAdminId_fkey"
        FOREIGN KEY ("createdByAdminId") REFERENCES "Admin"("id")
        ON DELETE SET NULL ON UPDATE CASCADE;
    END IF;
END $$;
