The biggest problem with working yourself into an “irreplaceable” position is that you’ll never get a promotion.
Second, the technology you’re currently working with isn’t irreplaceable. At some point, the company will realize there’s a risk in having their applications in an outdated, unsupported language or database. If you’re irreplaceable in this outdated technology, and you don’t know the new technology it will be built in, there’s a good chance your career will soon come to an end.
Also, keep in mind that everyone who thought they were replaceable eventually retired, or will retire – and the company will still manage to keep going.