When paracetamol plus a non steroidal drug (ibuprofen, naproxen, diclofenac or celecoxib) are sufficiant to control pain opioid drugs may need to be used. They cause constipation so should be co prescribed with a stool softener). They are also addictive so should be used for the shortest possible time, in the lowest possible dose.
Codeine is not recomemnded for breastfeeding https://breastfeeding-and-medication.co.uk/thoughts/breastfeeding-and-codeine but one accidental dose or short term use, maybe overnight when no other pain relief is available does not mean that breastfeeding needs to be interrupted.
No breastfeeding mother should ever be asked to choose between adequate pain relief and breastfeeding