It's a bit more complicated than that. It can be argued that if there is a clear link between contributions and pensions, promised pensions based on past contributions are private property, with the usual protections. I don't know the situation in Spain, but Finland at least has made that choice.
If you choose that (or if your legal system determines that), you need to be proactive with keeping the pension system in balance. While you can change what you promise in exchange for future contributions, substantial changes to what you have already promised can easily require constitutional amendments.
The argument is ultimately constitutional. If pensions based on past contribitions are private property, the government can't avoid paying them when it's no longer economically sustainable. The obligation remains even if the government is no longer capable of honoring it. Political choices and ordinary laws can't change that. The only way out is amending the constitution and socializing the private property.
If you choose that (or if your legal system determines that), you need to be proactive with keeping the pension system in balance. While you can change what you promise in exchange for future contributions, substantial changes to what you have already promised can easily require constitutional amendments.