M
M
Max Payne2018-10-27 13:48:04
PostgreSQL
Max Payne, 2018-10-27 13:48:04

Full Postgres schema cloning?

When using pg_dump / pg_restore, as far as I understand, in any case, you have to rename the original schema twice (first add some prefix / postfix, then restore the dump, then rename the dump, and then remove the prefix from the original one). This option doesn't work for me.
I looked at the scripts on gist.github.com - some of them do not copy the data, but expand the schema quite quickly, others that should copy the data do not work, for example this and this one due to max_value.
Are there any other options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eyeless_watcher, 2018-10-28
@eyeless_watcher

If you dump in plaintext format (--format=p), the resulting file can be edited and added to the beginning

create schema new_schema;
set search_path to new_schema;

Then, when executing it via `psql -f dump.sql` (not pg_restore), all manipulations will occur with the new schema.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question