summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rwxr-xr-xsql/Pg-tables.sql17
-rw-r--r--sql/Pg-upgrade-2.6.18-2.6.19.sql18
2 files changed, 34 insertions, 1 deletions
diff --git a/sql/Pg-tables.sql b/sql/Pg-tables.sql
index d512ccbb..5201e55e 100755
--- a/sql/Pg-tables.sql
+++ b/sql/Pg-tables.sql
@@ -757,3 +757,20 @@ COMMENT ON COLUMN users_conf.password IS 'This means we have to get rid of the c
-- The two below statements must be run from a single session
INSERT INTO users(username) VALUES ('admin');
INSERT INTO users_conf(id,password) VALUES (currval('users_id_seq'),NULL);
+
+
+CREATE FUNCTION create_user(text) RETURNS int4 AS $$
+ INSERT INTO users(username) VALUES ('$1');
+ SELECT 1;
+ $$ LANGUAGE 'SQL';
+
+COMMENT ON FUNCTION create_user(text) IS $$ Function to create user. Returns 1 if successful, else it is an error. $$;
+
+CREATE FUNCTION update_user(int4,text) RETURNS int4 AS $$
+ UPDATE users SET username = '$2' WHERE id = $1;
+ SELECT 1;
+ $$ LANGUAGE 'SQL';
+
+COMMENT ON FUNCTION update_user(int4,text) IS $$ Takes int4 which is users.id and text which is username. Will update username based on id. Username is unique $$;
+
+
diff --git a/sql/Pg-upgrade-2.6.18-2.6.19.sql b/sql/Pg-upgrade-2.6.18-2.6.19.sql
index f06f661e..ce34ab29 100644
--- a/sql/Pg-upgrade-2.6.18-2.6.19.sql
+++ b/sql/Pg-upgrade-2.6.18-2.6.19.sql
@@ -189,4 +189,20 @@ COMMIT;
BEGIN;
INSERT INTO users(username) VALUES ('admin');
INSERT INTO users_conf(id,password) VALUES (currval('users_id_seq'),NULL);
-COMMIT; \ No newline at end of file
+COMMIT;
+
+-- Functions
+
+CREATE FUNCTION create_user(text) RETURNS int4 AS $$
+ INSERT INTO users(username) VALUES ('$1');
+ SELECT 1;
+ $$ LANGUAGE 'SQL';
+
+COMMENT ON FUNCTION create_user(text) IS $$ Function to create user Returns 1 if successful, else it is an error. $$;
+
+CREATE FUNCTION update_user(int4,text) RETURNS int4 AS $$
+ UPDATE users SET username = '$2' WHERE id = $1;
+ SELECT 1;
+ $$ LANGUAGE 'SQL';
+
+COMMENT ON FUNCTION update_user(int4,text) IS $$ Takes int4 which is users.id and text which is username. Will update username based on id. Username is unique $$;