]> git.nbdom.net Git - nb.git/commitdiff
lib/postgres/url.sql
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 26 May 2018 01:59:48 +0000 (02:59 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 26 May 2018 01:59:48 +0000 (02:59 +0100)
lib/postgres/function/CONCAT.sql [new file with mode: 0644]
lib/postgres/functions.sql [deleted file]
lib/postgres/url.sql [new file with mode: 0644]

diff --git a/lib/postgres/function/CONCAT.sql b/lib/postgres/function/CONCAT.sql
new file mode 100644 (file)
index 0000000..1e13977
--- /dev/null
@@ -0,0 +1,33 @@
+-- NB 21.06.16 CREATE AGGREGATE array_agg (anyelement)
+-- NB 21.06.16 (
+-- NB 21.06.16   sfunc = array_append,
+-- NB 21.06.16   stype = anyarray,
+-- NB 21.06.16   initcond = '{}'
+-- NB 21.06.16 );
+
+DROP AGGREGATE IF EXISTS CONCAT(text);
+/*
+CREATE AGGREGATE CONCAT(
+  basetype    = text,
+  sfunc       = textcat,
+  stype       = text,
+  initcond    = ''
+
+);
+*/
+
+/*
+DROP FUNCTION IF EXISTS CONCAT( VARIADIC ANYARRAY );
+CREATE FUNCTION CONCAT( VARIADIC ANYARRAY )
+RETURNS TEXT
+ LANGUAGE SQL
+  IMMUTABLE
+  AS $$
+  SELECT array_to_string($1,'');
+$$;
+*/
+
+
+
+
+
diff --git a/lib/postgres/functions.sql b/lib/postgres/functions.sql
deleted file mode 100644 (file)
index 1e13977..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
--- NB 21.06.16 CREATE AGGREGATE array_agg (anyelement)
--- NB 21.06.16 (
--- NB 21.06.16   sfunc = array_append,
--- NB 21.06.16   stype = anyarray,
--- NB 21.06.16   initcond = '{}'
--- NB 21.06.16 );
-
-DROP AGGREGATE IF EXISTS CONCAT(text);
-/*
-CREATE AGGREGATE CONCAT(
-  basetype    = text,
-  sfunc       = textcat,
-  stype       = text,
-  initcond    = ''
-
-);
-*/
-
-/*
-DROP FUNCTION IF EXISTS CONCAT( VARIADIC ANYARRAY );
-CREATE FUNCTION CONCAT( VARIADIC ANYARRAY )
-RETURNS TEXT
- LANGUAGE SQL
-  IMMUTABLE
-  AS $$
-  SELECT array_to_string($1,'');
-$$;
-*/
-
-
-
-
-
diff --git a/lib/postgres/url.sql b/lib/postgres/url.sql
new file mode 100644 (file)
index 0000000..c973524
--- /dev/null
@@ -0,0 +1,28 @@
+DROP TABLE IF EXISTS content;
+CREATE TABLE IF NOT EXISTS content (
+  id SERIAL PRIMARY KEY,
+  type VARCHAR(250) NOT NULL,
+  title VARCHAR(250) NOT NULL,
+  created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+  updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+  content TEXT NOT NULL
+);
+CREATE INDEX IF NOT EXISTS content_created ON content USING btree (created);
+CREATE INDEX IF NOT EXISTS content_type ON content USING btree (type);
+CREATE INDEX IF NOT EXISTS content_title ON content USING btree (title);
+
+DROP FUNCTION IF EXISTS content_before_insert();
+/*
+*/
+CREATE FUNCTION content_before_insert() RETURNS trigger as 'BEGIN
+  NEW.updated = now();
+  RETURN NEW;
+END' LANGUAGE 'plpgsql';
+
+DROP TRIGGER IF EXISTS content_before_insert ON content;
+/*
+*/
+CREATE TRIGGER content_before_insert BEFORE INSERT OR UPDATE ON content
+FOR EACH ROW
+EXECUTE PROCEDURE content_before_insert()
+;