In general, "grandfather" clauses when something like the plumbing or electrical code changes, apply ONLY to existing, unchanged or modified situations. When you change it or replace it, all new codes apply. Many times, jurisdictions require certain things to be brought to current code at the time of sale of the property. Some common examples are requiring all 1.6 gpf toilets, earthquake straps on WH, safetybeam controls on automatic garage door, etc. And then the ubiquitous home inspector will flag other items, which will not mandated by law....if you want to close the deal, you have to play ball.
PERMITS: MANDATORY virtually anywhere, for any electrical or plumbing beyond very minor repairs, even if you do the work yourself. Again, this will come back to bite you in the butt big time later.