Add postgresql.create_schema()

This commit is contained in:
Lance Edgar 2019-10-04 23:08:39 -05:00
parent 0b5f6234ad
commit 325f85a4b3

View file

@ -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.