Stable variables persistence

I have something always worrying me about data persistence, I know stable variables keeps the data permanent, but what is someone changes the model accidentally, then the data is lost for ever in this case. My suggestion is that when model changes in stable variables, the code should not compile, and to delete a stable variable, there should be two ways, 1- By adding a feature to DFX to delete the variable, and issue for example dfx canister stable delete canister_id.stablevariable
then dfx deploy, the dfx canister delete would only add a flag to dfx to continue build as usual, and if that can be anoying we should add a flag to dfx deploy like dfx deploy --ignore-stable-error
Then it would go ahead and delete the stable variable/s without any errors

2- Issuing delete command in code and deploy for example

as usual Create a new stable variable, and copy the data from MODEL_OLD to MODEL_NEW
add new keyword to delete the variable → delete … MODEL_OLD;

Hi @jaxopaxo,
Thank you for reaching out. I completely understand your worries about accidental deletion of data. However, dfx should warn (even with an error message) when stable variables in Motoko are deleted. Interactive consent of the user is asked and the removed variables will be listed. We do not recommend passing this warning. Instead, if a stable variable is no longer needed, programers can promote its type to Any such that the upgrade works without warning. Please let me know if you encountered a case where this warning is not shown as this would be a bug.
In the future, we plan more rigorous compatibility checks on upgrade that cannot be bypassed by a warning. However, I appreciate your suggestions as this would indeed be a useful improvement if dfx requires users to explicitly name the stable variables that should be deleted.

Hi @jaxopaxo,
A follow up: I just noticed that the dfx warning is not displayed in case of dropped stable variable, although it is implemented in the corresponding internal Motoko check function. This seems to be indeed an issue. I’ll check with the team that we can fix this. I’ll keep you posted.

Thank you very much for reporting this!

I wonder which dfx and Motoko version you are using when observing the issue that dfx does not warn about dropping stable variables?