Here's one for my memory missing that there was already a custom sql file
authorMagnus Hagander <magnus@hagander.net>
Sun, 12 Aug 2012 15:58:24 +0000 (17:58 +0200)
committerMagnus Hagander <magnus@hagander.net>
Sun, 12 Aug 2012 15:58:24 +0000 (17:58 +0200)
django/archives/mailarchives/models.py
loader/sql/schema.sql
sql/custom.sql [deleted file]

index a6b13dd4756a7eeb35cd0659c5da1b57361b0e3e..5325264c9d10c930fcd4bdffc1e372877ce660fe 100644 (file)
@@ -6,7 +6,7 @@ class Message(models.Model):
        to = models.TextField(null=False, db_column='_to')
        cc = models.TextField(null=False)
        subject = models.TextField(null=False)
-       date = models.DateTimeField(null=False, db_index=True)
+       date = models.DateTimeField(null=False)
        messageid = models.TextField(null=False)
        bodytxt = models.TextField(null=False)
        # rawtxt is a bytea field, which django doesn't support (easily)
index 8797a382def234b40b1a6100f1c307070dae87e4..e84704b4bd8dee1d72bf9967dd246a15dec246cd 100644 (file)
@@ -12,7 +12,8 @@ CREATE TABLE messages (
    has_attachment boolean NOT NULL,
    messageid text NOT NULL,
    bodytxt text NOT NULL,
-   rawtxt bytea NOT NULL
+   rawtxt bytea NOT NULL,
+   fti tsvector NOT NULL
 );
 CREATE INDEX idx_messages_threadid ON messages(threadid);
 CREATE UNIQUE INDEX idx_messages_msgid ON messages(messageid);
@@ -83,4 +84,42 @@ CREATE TABLE legacyurls(
    month int NOT NULL,
    seq int NOT NULL,
    msgid text NOT NULL
-);
\ No newline at end of file
+);
+
+
+/* textsearch configs */
+CREATE TEXT SEARCH CONFIGURATION pg (COPY = pg_catalog.english );
+
+CREATE TEXT SEARCH DICTIONARY english_ispell (
+   TEMPLATE = ispell,
+   DictFile = en_us,
+   AffFile = en_us,
+   StopWords = english
+);
+CREATE TEXT SEARCH DICTIONARY pg_dict (
+   TEMPLATE = synonym,
+   SYNONYMS = pg_dict
+);
+CREATE TEXT SEARCH DICTIONARY pg_stop (
+   TEMPLATE = simple,
+   StopWords = pg_dict
+);
+ALTER TEXT SEARCH CONFIGURATION pg
+   ALTER MAPPING FOR asciiword, asciihword, hword_asciipart,
+                     word, hword, hword_part
+    WITH pg_stop, pg_dict, english_ispell, english_stem;
+ALTER TEXT SEARCH CONFIGURATION pg
+   DROP MAPPING FOR email, url, url_path, sfloat, float;
+
+CREATE FUNCTION messages_fti_trigger_func() RETURNS trigger AS $$
+BEGIN
+   NEW.fti = setweight(to_tsvector('public.pg', coalesce(new.subject, '')), 'A') ||
+             setweight(to_tsvector('public.pg', coalesce(new.bodytxt, '')), 'D');
+   RETURN NEW;
+END
+$$ LANGUAGE 'plpgsql';
+
+CREATE TRIGGER messages_fti_trigger
+ BEFORE INSERT OR UPDATE OF subject, bodytxt ON  messages
+ FOR EACH ROW EXECUTE PROCEDURE messages_fti_trigger_func();
+CREATE INDEX messages_fti_idx ON messages USING gin(fti);
diff --git a/sql/custom.sql b/sql/custom.sql
deleted file mode 100644 (file)
index 2eae012..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-CREATE TEXT SEARCH CONFIGURATION pg (COPY = pg_catalog.english );
-
-CREATE TEXT SEARCH DICTIONARY english_ispell (
-   TEMPLATE = ispell,
-   DictFile = en_us,
-   AffFile = en_us,
-   StopWords = english
-);
-CREATE TEXT SEARCH DICTIONARY pg_dict (
-   TEMPLATE = synonym,
-   SYNONYMS = pg_dict
-);
-CREATE TEXT SEARCH DICTIONARY pg_stop (
-   TEMPLATE = simple,
-   StopWords = pg_dict
-);
-ALTER TEXT SEARCH CONFIGURATION pg
-   ALTER MAPPING FOR asciiword, asciihword, hword_asciipart,
-                     word, hword, hword_part
-    WITH pg_stop, pg_dict, english_ispell, english_stem;
-ALTER TEXT SEARCH CONFIGURATION pg
-   DROP MAPPING FOR email, url, url_path, sfloat, float;
-
-ALTER TABLE messages ADD COLUMN rawtxt bytea;
-ALTER TABLE messages ADD COLUMN fti tsvector;
-
-CREATE FUNCTION messages_fti_trigger_func() RETURNS trigger AS $$
-BEGIN
-   NEW.fti = setweight(to_tsvector('public.pg', coalesce(new.subject, '')), 'A') ||
-             setweight(to_tsvector('public.pg', coalesce(new.bodytxt, '')), 'D');
-   RETURN NEW;
-END
-$$ LANGUAGE 'plpgsql';
-
-CREATE TRIGGER messages_fti_trigger
- BEFORE INSERT OR UPDATE OF subject, bodytxt ON  messages
- FOR EACH ROW EXECUTE PROCEDURE messages_fti_trigger_func();
-CREATE INDEX messages_fti_idx ON messages USING gin(fti);