2006-04-30 17:36:16 +00:00
|
|
|
-- SQL to create the initial tables for the MediaWiki database.
|
|
|
|
|
-- This is read and executed by the install script; you should
|
|
|
|
|
-- not have to run it by itself unless doing a manual install.
|
|
|
|
|
-- This is the PostgreSQL version.
|
2006-06-29 01:44:12 +00:00
|
|
|
-- For information about each table, please see the notes in maintenance/tables.sql
|
2006-04-30 17:36:16 +00:00
|
|
|
-- Please make sure all dollar-quoting uses $mw$ at the start of the line
|
2008-03-02 16:42:24 +00:00
|
|
|
-- TODO: Change CHAR/SMALLINT to BOOL (still used in a non-bool fashion in PHP code)
|
2006-04-30 17:36:16 +00:00
|
|
|
|
2006-07-05 03:49:36 +00:00
|
|
|
BEGIN;
|
2006-04-30 17:36:16 +00:00
|
|
|
SET client_min_messages = 'ERROR';
|
|
|
|
|
|
2006-07-05 03:49:36 +00:00
|
|
|
-- Tsearch2 2 stuff. Will fail if we don't have proper access to the tsearch2 tables
|
2008-02-19 01:06:06 +00:00
|
|
|
-- Make sure you also change patch-tsearch2funcs.sql if the funcs below change.
|
2006-07-05 03:49:36 +00:00
|
|
|
ALTER TABLE page ADD titlevector tsvector;
|
|
|
|
|
CREATE FUNCTION ts2_page_title() RETURNS TRIGGER LANGUAGE plpgsql AS
|
|
|
|
|
$mw$
|
|
|
|
|
BEGIN
|
|
|
|
|
IF TG_OP = 'INSERT' THEN
|
2011-02-03 04:06:11 +00:00
|
|
|
NEW.titlevector = to_tsvector(REPLACE(NEW.page_title,'/',' '));
|
2006-07-05 03:49:36 +00:00
|
|
|
ELSIF NEW.page_title != OLD.page_title THEN
|
2011-02-03 04:06:11 +00:00
|
|
|
NEW.titlevector := to_tsvector(REPLACE(NEW.page_title,'/',' '));
|
2006-07-05 03:49:36 +00:00
|
|
|
END IF;
|
|
|
|
|
RETURN NEW;
|
|
|
|
|
END;
|
|
|
|
|
$mw$;
|
|
|
|
|
|
|
|
|
|
CREATE TRIGGER ts2_page_title BEFORE INSERT OR UPDATE ON page
|
2006-07-22 17:30:39 +00:00
|
|
|
FOR EACH ROW EXECUTE PROCEDURE ts2_page_title();
|
2006-05-25 00:44:55 +00:00
|
|
|
|
2006-04-30 17:36:16 +00:00
|
|
|
|
2020-12-23 03:59:12 +00:00
|
|
|
ALTER TABLE text ADD textvector tsvector;
|
2006-07-05 03:49:36 +00:00
|
|
|
CREATE FUNCTION ts2_page_text() RETURNS TRIGGER LANGUAGE plpgsql AS
|
|
|
|
|
$mw$
|
|
|
|
|
BEGIN
|
|
|
|
|
IF TG_OP = 'INSERT' THEN
|
2011-02-03 04:06:11 +00:00
|
|
|
NEW.textvector = to_tsvector(NEW.old_text);
|
2006-07-05 03:49:36 +00:00
|
|
|
ELSIF NEW.old_text != OLD.old_text THEN
|
2011-02-03 04:06:11 +00:00
|
|
|
NEW.textvector := to_tsvector(NEW.old_text);
|
2006-07-05 03:49:36 +00:00
|
|
|
END IF;
|
|
|
|
|
RETURN NEW;
|
|
|
|
|
END;
|
|
|
|
|
$mw$;
|
|
|
|
|
|
2020-12-23 03:59:12 +00:00
|
|
|
CREATE TRIGGER ts2_page_text BEFORE INSERT OR UPDATE ON text
|
2006-07-22 17:30:39 +00:00
|
|
|
FOR EACH ROW EXECUTE PROCEDURE ts2_page_text();
|
2006-06-29 01:44:12 +00:00
|
|
|
|
2008-02-10 15:38:48 +00:00
|
|
|
CREATE INDEX ts2_page_title ON page USING gin(titlevector);
|
2020-12-23 03:59:12 +00:00
|
|
|
CREATE INDEX ts2_page_text ON text USING gin(textvector);
|