Skip to content

Instantly share code, notes, and snippets.

@cayetanobv
Created July 20, 2018 16:50
Show Gist options
  • Save cayetanobv/188ffc21d41fecb1ec5b15bc2c04c56f to your computer and use it in GitHub Desktop.
Save cayetanobv/188ffc21d41fecb1ec5b15bc2c04c56f to your computer and use it in GitHub Desktop.
DROP FUNCTION IF EXISTS testing_environments_path(text);
CREATE OR REPLACE FUNCTION testing_environments_path(
dbschema text
)
RETURNS void AS
$$
BEGIN
EXECUTE format('CREATE SCHEMA %I;', dbschema);
EXECUTE format('SET LOCAL search_path TO %I,public', dbschema);
CREATE TABLE testing_table_to_delete (
id serial PRIMARY KEY,
name text
);
INSERT INTO testing_table_to_delete (name)
VALUES
('one'), ('two'), ('three');
END;
$$ LANGUAGE plpgsql;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment