summaryrefslogtreecommitdiff
path: root/maintenance/postgres/archives
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/postgres/archives')
-rw-r--r--maintenance/postgres/archives/patch-category.sql15
-rw-r--r--maintenance/postgres/archives/patch-page_props.sql9
-rw-r--r--maintenance/postgres/archives/patch-tsearch2funcs.sql29
-rw-r--r--maintenance/postgres/archives/patch-updatelog.sql4
4 files changed, 57 insertions, 0 deletions
diff --git a/maintenance/postgres/archives/patch-category.sql b/maintenance/postgres/archives/patch-category.sql
new file mode 100644
index 00000000..5e0d620f
--- /dev/null
+++ b/maintenance/postgres/archives/patch-category.sql
@@ -0,0 +1,15 @@
+
+CREATE SEQUENCE category_id_seq;
+
+CREATE TABLE category (
+ cat_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('category_id_seq'),
+ cat_title TEXT NOT NULL,
+ cat_pages INTEGER NOT NULL DEFAULT 0,
+ cat_subcats INTEGER NOT NULL DEFAULT 0,
+ cat_files INTEGER NOT NULL DEFAULT 0,
+ cat_hidden SMALLINT NOT NULL DEFAULT 0
+);
+
+CREATE UNIQUE INDEX category_title ON category(cat_title);
+CREATE INDEX category_pages ON category(cat_pages);
+
diff --git a/maintenance/postgres/archives/patch-page_props.sql b/maintenance/postgres/archives/patch-page_props.sql
new file mode 100644
index 00000000..ab707022
--- /dev/null
+++ b/maintenance/postgres/archives/patch-page_props.sql
@@ -0,0 +1,9 @@
+
+CREATE TABLE page_props (
+ pp_page INTEGER NOT NULL REFERENCES page (page_id) ON DELETE CASCADE,
+ pp_propname TEXT NOT NULL,
+ pp_value TEXT NOT NULL
+);
+ALTER TABLE page_props ADD CONSTRAINT page_props_pk PRIMARY KEY (pp_page,pp_propname);
+CREATE INDEX page_props_propname ON page_props (pp_propname);
+
diff --git a/maintenance/postgres/archives/patch-tsearch2funcs.sql b/maintenance/postgres/archives/patch-tsearch2funcs.sql
new file mode 100644
index 00000000..c24efef3
--- /dev/null
+++ b/maintenance/postgres/archives/patch-tsearch2funcs.sql
@@ -0,0 +1,29 @@
+-- Should be run on Postgres 8.3 or newer to remove the 'default'
+
+CREATE OR REPLACE FUNCTION ts2_page_title()
+RETURNS TRIGGER
+LANGUAGE plpgsql AS
+$mw$
+BEGIN
+IF TG_OP = 'INSERT' THEN
+ NEW.titlevector = to_tsvector(REPLACE(NEW.page_title,'/',' '));
+ELSIF NEW.page_title != OLD.page_title THEN
+ NEW.titlevector := to_tsvector(REPLACE(NEW.page_title,'/',' '));
+END IF;
+RETURN NEW;
+END;
+$mw$;
+
+CREATE OR REPLACE FUNCTION ts2_page_text()
+RETURNS TRIGGER
+LANGUAGE plpgsql AS
+$mw$
+BEGIN
+IF TG_OP = 'INSERT' THEN
+ NEW.textvector = to_tsvector(NEW.old_text);
+ELSIF NEW.old_text != OLD.old_text THEN
+ NEW.textvector := to_tsvector(NEW.old_text);
+END IF;
+RETURN NEW;
+END;
+$mw$;
diff --git a/maintenance/postgres/archives/patch-updatelog.sql b/maintenance/postgres/archives/patch-updatelog.sql
new file mode 100644
index 00000000..dda80aa4
--- /dev/null
+++ b/maintenance/postgres/archives/patch-updatelog.sql
@@ -0,0 +1,4 @@
+
+CREATE TABLE updatelog (
+ ul_key TEXT NOT NULL PRIMARY KEY
+);