Skip to content

Instantly share code, notes, and snippets.

@rocksfrow
rocksfrow / clone_schema_fn.sql
Last active July 13, 2022 10:19
enhanced postgresql clone_schema() function with trigger + foreign key support
CREATE OR REPLACE FUNCTION clone_schema(source_schema text, dest_schema text) RETURNS void AS
$$
DECLARE
object text;
buffer text;
default_ text;
column_ text;
constraint_name_ text;
constraint_def_ text;