X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/d541c6185fb0f426dce0b16e85327b53635169e0..HEAD:/src/plugins/postgres.sml diff --git a/src/plugins/postgres.sml b/src/plugins/postgres.sml index a267e4f..fda5801 100644 --- a/src/plugins/postgres.sml +++ b/src/plugins/postgres.sml @@ -1,5 +1,6 @@ (* HCoop Domtool (http://hcoop.sourceforge.net/) * Copyright (c) 2006, Adam Chlipala + * Copyright (c) 2012 Clinton Ebadi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,12 +21,27 @@ structure Postgres :> POSTGRES = struct -fun adduser user = - if Slave.shell [Config.Postgres.adduser, user] then - NONE - else - SOME "Error executing CREATE USER script" +fun adduser port {user, passwd} = + Option.map (fn s => "Error executing CREATE USER script:\n" ^ s) + (Slave.shellOutput [Config.Postgres.adduser, " ", port, " ", user]) -val _ = Dbms.register ("postgres", {adduser = adduser}) +fun passwd _ = SOME "We don't use PostgreSQL passwords." + +fun createdb port {user, dbname, encoding} = + Option.map (fn s => "Error executing CREATE DATABASE script:\n" ^ s) + (Slave.shellOutput [Config.Postgres.createdb, + " ", port, " ", user, " ", dbname, + case encoding of NONE => "" | SOME e => " " ^ e]) + +fun dropdb port {user, dbname} = + Option.map (fn s => "Error executing DROP DATABASE script:\n" ^ s) + (Slave.shellOutput [Config.Postgres.dropdb, " ", port, " ", user, " ", dbname]) + +val _ = Dbms.register ("postgres-9", {getpass = NONE, + adduser = adduser Config.Postgres.postgres9port, + passwd = passwd, + createdb = createdb Config.Postgres.postgres9port, + dropdb = dropdb Config.Postgres.postgres9port, + grant = fn _ => SOME "You don't need to use GRANT for Postgres."}) end