apache: fix missing newline in fastScriptAlias
[hcoop/domtool2.git] / src / plugins / postgres.sml
1 (* HCoop Domtool (http://hcoop.sourceforge.net/)
2 * Copyright (c) 2006, Adam Chlipala
3 * Copyright (c) 2012 Clinton Ebadi <clinton@unknownlamer.org>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *)
19
20 (* PostgreSQL user/table management *)
21
22 structure Postgres :> POSTGRES = struct
23
24 fun adduser port {user, passwd} =
25 Option.map (fn s => "Error executing CREATE USER script:\n" ^ s)
26 (Slave.shellOutput [Config.Postgres.adduser, " ", port, " ", user])
27
28 fun passwd _ = SOME "We don't use PostgreSQL passwords."
29
30 fun createdb port {user, dbname, encoding} =
31 Option.map (fn s => "Error executing CREATE DATABASE script:\n" ^ s)
32 (Slave.shellOutput [Config.Postgres.createdb,
33 " ", port, " ", user, " ", dbname,
34 case encoding of NONE => "" | SOME e => " " ^ e])
35
36 fun dropdb port {user, dbname} =
37 Option.map (fn s => "Error executing DROP DATABASE script:\n" ^ s)
38 (Slave.shellOutput [Config.Postgres.dropdb, " ", port, " ", user, " ", dbname])
39
40 val _ = Dbms.register ("postgres", {getpass = NONE,
41 adduser = adduser Config.Postgres.postgres81port,
42 passwd = passwd,
43 createdb = createdb Config.Postgres.postgres81port,
44 dropdb = dropdb Config.Postgres.postgres81port,
45 grant = fn _ => SOME "You don't need to use GRANT for Postgres."})
46
47 val _ = Dbms.register ("postgres-9.1", {getpass = NONE,
48 adduser = adduser Config.Postgres.postgres91port,
49 passwd = passwd,
50 createdb = createdb Config.Postgres.postgres91port,
51 dropdb = dropdb Config.Postgres.postgres91port,
52 grant = fn _ => SOME "You don't need to use GRANT for Postgres."})
53
54 end