private function migrate_notification($notification, $isread) {
        global $DB;

        $tabledata = new \stdClass();
        $tabledata->useridfrom = $notification->useridfrom;
        $tabledata->useridto = $notification->useridto;
        $tabledata->subject = $notification->subject;
        $tabledata->fullmessage = $notification->fullmessage;
        $tabledata->fullmessageformat = $notification->fullmessageformat ?? FORMAT_MOODLE;
        $tabledata->fullmessagehtml = $notification->fullmessagehtml;
        $tabledata->smallmessage = $notification->smallmessage;
        $tabledata->component = $notification->component;
        $tabledata->eventtype = $notification->eventtype;
        $tabledata->contexturl = $notification->contexturl;
        $tabledata->contexturlname = $notification->contexturlname;
        $tabledata->timeread = $notification->timeread ?? null;
        $tabledata->timecreated = $notification->timecreated;

        $newid = $DB->insert_record('notifications', $tabledata);

        // Check if there is a record to move to the new 'message_popup_notifications' table.
        if ($mp = $DB->get_record('message_popup', ['messageid' => $notification->id, 'isread' => (int) $isread])) {
            $mpn = new \stdClass();
            $mpn->notificationid = $newid;
            $DB->insert_record('message_popup_notifications', $mpn);

            $DB->delete_records('message_popup', ['id' => $mp->id]);
        }
    }