Is this easier for someone who was a "domain expert" in an obsolete domain than for a programming generalist? i.e. could a programming generalist also "own" a domain in a couple years?
I was surprised several times, and have since stopped being surprised, that someone who was immersed in a technology for years, loved it intimately, and knew every wart on its asshole, so to speak, and loved it anyway, the person you know as the guy who's really into PHP or the guy who's really into Oracle or the guy who's really into jQuery will not flail when the company abandons that technology. I would always worry, and think to myself, "Man, using PHP at least we have Tom. I'm not sure upgrading to a better technology is worth losing that kind of expertise. And what will poor Tom do now? PHP is his whole life." And of course six months later Tom knows every wart on the asshole of Node and React/Redux. Tom was an expert because he had an ability to take an obsessive interest in something and create his own expertise. Non-technology domains are similar, with one caveat. Somebody who is a master of a customer domain got that way by being able to take an interest and being able to empathize with customers, get them talking, and keep them talking. They can apply that to a new domain and get up to speed with terrifying speed. The caveat is that some people have domain knowledge from working in a field for years before getting into software development, and they can't replicate that experience in a new domain.
Can't upvote this enough. In my experience, if you have the capacity for the occasional obsessive voracious burst of knowledge acquisition, there's no limit to the amount of technology cycles you'll be able to surf, and you'll always be able to sell your expertise and get good work. I feel bad for the calmer more balanced people who don't have that manic streak, who leave work at work, they'll always be at a disadvantage.
I'd like to think I'm becoming Tom here, right down to the techs you mentioned. I also went through git, apache httpd, bash, and Ruby phases.
My philosophy is that if PHP keeps the lights on, I better really know what it is, where it's going, what are it's limitations, because it would be pretty scary not to.
Plus once you learn a language or a database well, the next one is easier. The trick is knowing when it's time for the next one.