If you use Yoast SEO to manage redirects and you change your permalink structure you may need to update a large amount of your redirects.
Here is a small simple script to help with that. This was made for when you switch from
https://www.sethryder.com/sample-post/. If you are switching to something else it should be easy to modify, you will just need to update the regex in the preg_replace.
The two rows you will want to run through this script in your database are the
wp_options. I assume they may vary if you are not using the premium version of the plugin.
This script will take the serialized options in the database (that you copy into the expected text files) and go through them and remove/update the redirect links. Once finished it writes them to the new files and you can replace the rows in your database.