Re: feature request: pg_restore renaming target schema

From: John Scalia <jayknowsunix(at)gmail(dot)com>
To: CN <cnliou9(at)fastmail(dot)fm>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: feature request: pg_restore renaming target schema
Date: 2015-12-17 15:34:12
Message-ID: CABzCKRCYkP400=0ZqOKPsYEb7twKjX8fcQ96hFMGf+6ZsGys=A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Maybe a bit off-postgresql, but why couldn't you just add to your existing
automations script, Use sed or your favorite stream editor and have that do
the renaming in the dump output?

FWIW,
Jay

On Thu, Dec 17, 2015 at 9:19 AM, CN <cnliou9(at)fastmail(dot)fm> wrote:

> Thank you! Venkataramana,
>
> On Thu, Dec 17, 2015, at 09:20 PM, Shreeyansh Dba wrote:
>
> But if you are trying to do with second option like from source schema(s1)
> of db1 to target schema(t1) of db2, it is not possible with pg_restore
> because while restoring from backup dump, it follows the sequence of
> commands like
> "CREATE SCHEMA s1"
> "SET SEARCH_PATH=s1"
> "CREATE TABLE table_name(id int)"
> "INSERT INTO table_name VALUES(1)"
>
>
> Indeed. I have just peeked the content of the dumped file in plain format
> and have noticed that all objects are prefixed with original schema name.
> This makes me feel that the task of adding the mentioned feature to
> pg_restore or pg_dump must be nontrivial :-(
>
>
> 2: If you are taking the dump in plan text format you can edit the plain
> text file and replace schema old name to new name and then you can restore
> the file using psql -d <db> -U <user> -f <path of plain text file>.
>
>
>
> Manual editing is not quite feasible because I need to automate the
> sequence of jobs by executing pg_dump and pg_restore in program.
>
> Best Regards,
> CN
>
> -- http://www.fastmail.com - Accessible with your email software
> or over the web
>
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message CN 2015-12-17 16:18:28 Re: feature request: pg_restore renaming target schema
Previous Message CN 2015-12-17 15:19:46 Re: feature request: pg_restore renaming target schema