Is there a way in PostgreSQL to check whether the current context is during
CREATE EXTENSION or
ALTER EXTENSION … UPDATE?
I'm switching over some of my schemas that I managed with my home-brewed PostgreSQL migration framework to be based on extensions instead. In my migration framework, I had various way to see if I was running within a migration, and I would like to see something similar during extension installation/upgrade.
Maybe I must throw and catch an exception and inspect the stack? I hope not…
Context [added Nov. 21, '22]: I would like to create an event trigger that ignores events that are part of extension installation and upgrade. To be honest, I don't really need this. (I realized that, within my use case, extension installation is handled from within migrations anyway.) But, as a theoretical exercise, I still would like to know if this is possible.