 SET search_path = cforum, pg_catalog;
 
 --
--- Name: threads__count_delete_forum_trigger; Type: TRIGGER; Schema: cforum; Owner: -
---
-
-CREATE TRIGGER threads__count_delete_forum_trigger AFTER DELETE ON forums FOR EACH ROW EXECUTE PROCEDURE count_threads_delete_forum_trigger();
+-- Name: messages__count_delete_trigger; Type: TRIGGER; Schema: cforum; Owner: -
+--
+
+CREATE TRIGGER messages__count_delete_trigger AFTER DELETE ON messages FOR EACH ROW EXECUTE PROCEDURE count_messages_delete_trigger();
+
+
+--
+-- Name: messages__count_insert_forum_trigger; Type: TRIGGER; Schema: cforum; Owner: -
+--
+
+CREATE TRIGGER messages__count_insert_forum_trigger AFTER INSERT ON forums FOR EACH STATEMENT EXECUTE PROCEDURE count_messages_insert_forum_trigger();
+
+
+--
+-- Name: messages__count_insert_trigger; Type: TRIGGER; Schema: cforum; Owner: -
+--
+
+CREATE TRIGGER messages__count_insert_trigger AFTER INSERT ON messages FOR EACH ROW EXECUTE PROCEDURE count_messages_insert_trigger();
+
+
+--
+-- Name: messages__count_truncate_trigger; Type: TRIGGER; Schema: cforum; Owner: -
+--
+
+CREATE TRIGGER messages__count_truncate_trigger AFTER TRUNCATE ON messages FOR EACH STATEMENT EXECUTE PROCEDURE count_messages_truncate_trigger();
 
 
 --



--
-- Name: threads__count_truncate_forum_trigger; Type: TRIGGER; Schema: cforum; Owner: -
--

CREATE TRIGGER threads__count_truncate_forum_trigger AFTER TRUNCATE ON forums FOR EACH STATEMENT EXECUTE PROCEDURE count_threads_truncate_forum_trigger();


--
-- Name: threads__count_truncate_trigger; Type: TRIGGER; Schema: cforum; Owner: -
--

CREATE TRIGGER threads__count_truncate_trigger AFTER TRUNCATE ON threads FOR EACH STATEMENT EXECUTE PROCEDURE count_threads_truncate_trigger();


--

      RAISE NOTICE 'table_count: summing counter';

      FOR v_cur_id, v_cur_difference IN
        SELECT count_id, difference
        FROM
          cforum.counter_table
        WHERE
