pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedSchema renaming cascade
2+ messages / 2 participants
[nested] [flat]
* Schema renaming cascade
@ 2023-08-17 15:43 Lorusso Domenico <domenico.l76@gmail.com>
2023-08-17 15:54 ` Re: Schema renaming cascade Alvaro Herrera <alvherre@alvh.no-ip.org>
0 siblings, 1 reply; 2+ messages in thread
From: Lorusso Domenico @ 2023-08-17 15:43 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hello guys,
I need to rename a schema, including each reference to it (also for
functions)
I mean:
I've 2 schemas called "schema1" and "schema2".
In schema1 there are tables, composite types, and functions
Functions call other functions in the same schema
In schema2
Also in schema2 there are tables, composite types, and functions
Plus many function and tables refer to object of schema1
I need to rename schema1 to schema 3 substituting any reference to schema1
with schema3
Is there a way to to that?
I found this answer
<https://www.postgresql.org/message-id/CANu8FiyJtt-0q%3DbkUxyra66tHi6FFzgU8TqVR2aahseCBDDntA%40mail.g...;
that
clone a schema (that solve partially the problem) but is it still working
for v15?
At the end, I need to replace schema1 with schema3 for each function
(because table and type are automatically update)
Any suggestions?
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Schema renaming cascade
2023-08-17 15:43 Schema renaming cascade Lorusso Domenico <domenico.l76@gmail.com>
@ 2023-08-17 15:54 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
0 siblings, 0 replies; 2+ messages in thread
From: Alvaro Herrera @ 2023-08-17 15:54 UTC (permalink / raw)
To: Lorusso Domenico <domenico.l76@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
On 2023-Aug-17, Lorusso Domenico wrote:
> Hello guys,
> I need to rename a schema, including each reference to it (also for
> functions)
Maybe you should consider removing schema name references in function
source code, and instead refer to the tables (and other functions, etc)
by their unqualified names, and at the same time attach a "SET
search_path" clause to the function. That way, when you need to rename
the schema you don't need to change the function source code, just
update its "SET search_path" clause.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2023-08-17 15:54 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-08-17 15:43 Schema renaming cascade Lorusso Domenico <domenico.l76@gmail.com>
2023-08-17 15:54 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox