Currently IMPORT FOREIGN SCHEMA does not seem to support IF NOT EXISTS so how to solve this case? If I have a script that runs on every reboot for example I would get
ERROR: relation "xxx" already exists
Is there a way to overcome this?
Currently IMPORT FOREIGN SCHEMA does not seem to support IF NOT EXISTS so how to solve this case? If I have a script that runs on every reboot for example I would get
ERROR: relation "xxx" already exists
Is there a way to overcome this?
Use the EXCEPT clause to exclude those tables that are already there:
IMPORT FOREIGN SCHEMA xy EXCEPT (xxx, yyy, zzz) FROM ...
Alternatively, delete all foreign tables first. Creating them again shouldn't take too long.
IF NOT EXISTS.EXCEPT clause from them as suggested by my answer. That can be a single statement in psql if you use \gexec.