From 325f85a4b3deb3992d4020dd999f89a4bf175a23 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 4 Oct 2019 23:08:39 -0500 Subject: [PATCH] Add `postgresql.create_schema()` --- rattail_fabric2/postgresql.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rattail_fabric2/postgresql.py b/rattail_fabric2/postgresql.py index ebd224a..481f116 100644 --- a/rattail_fabric2/postgresql.py +++ b/rattail_fabric2/postgresql.py @@ -115,6 +115,14 @@ def create_db(c, name, owner=None, port=None, checkfirst=True): c.sudo(cmd, user='postgres') +def create_schema(c, name, dbname, owner='rattail', port=None): + """ + Create a schema within a PostgreSQL database. + """ + sql_ = "create schema if not exists {} authorization {}".format(name, owner) + sql(c, sql_, database=dbname, port=port) + + def drop_db(c, name, checkfirst=True): """ Drop a PostgreSQL database.