I need to clone a Postgres schema programatically in nodejs.
I have tried this approach
How to duplicate schemas in PostgreSQL
but it is quite old and could not make it work.
I have tried using pg_dump with -s flag to copy the schema structure then replacing in that file all the ocurrencies of the original schema for the new schema name.
Then i run psql instead of pg_restore because the file is not compatible with that command.
psql lims -U lims -h localhost -f new_schema.dump
psql:new_schema.dump:1127: ERROR: no existe el esquema «cliente2»
How could i create the schema programatically?