Skip to content
This repository
Browse code

добавление колонки БД чтобы различать избранные темы и отслеживаемые …

…(для #261)
  • Loading branch information...
commit a5dc423ae6bb89e0878b70269328de93bce69e10 1 parent 0de273f
Maxim Valyanskiy maxcom authored

Showing 2 changed files with 54 additions and 0 deletions. Show diff stats Hide diff stats

  1. +1 0  sql/main.xml
  2. +53 0 sql/updates/2012-05-11-memories-type.xml
1  sql/main.xml
@@ -23,5 +23,6 @@
23 23 <include file="sql/updates/2012-05-04-comdel-to-java.xml"/>
24 24 <include file="sql/updates/2012-05-06-remove-groups-stat4.xml"/>
25 25 <include file="sql/updates/2012-05-06-optimize-statupdate2.xml"/>
  26 + <include file="sql/updates/2012-05-11-memories-type.xml"/>
26 27
27 28 </databaseChangeLog>
53 sql/updates/2012-05-11-memories-type.xml
... ... @@ -0,0 +1,53 @@
  1 +<!--
  2 + ~ Copyright 1998-2012 Linux.org.ru
  3 + ~ Licensed under the Apache License, Version 2.0 (the "License");
  4 + ~ you may not use this file except in compliance with the License.
  5 + ~ You may obtain a copy of the License at
  6 + ~
  7 + ~ http://www.apache.org/licenses/LICENSE-2.0
  8 + ~
  9 + ~ Unless required by applicable law or agreed to in writing, software
  10 + ~ distributed under the License is distributed on an "AS IS" BASIS,
  11 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 + ~ See the License for the specific language governing permissions and
  13 + ~ limitations under the License.
  14 + -->
  15 +
  16 +<databaseChangeLog
  17 + xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  18 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19 + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
  20 + http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
  21 +
  22 + <changeSet id="2012051101" author="Maxim Valyanskiy">
  23 + <addColumn tableName="memories">
  24 + <column name="watch" type="boolean" defaultValueBoolean="true">
  25 + <constraints nullable="false"/>
  26 + </column>
  27 + </addColumn>
  28 + <sql>
  29 + drop index memories_un;
  30 + create unique index memories_un on memories(userid,topic,watch);
  31 + </sql>
  32 + </changeSet>
  33 + <changeSet id="2012051102" author="Maxim Valyanskiy">
  34 + <sql splitStatements="false">
  35 +CREATE OR REPLACE FUNCTION event_comment() RETURNS trigger
  36 + LANGUAGE plpgsql
  37 + AS $$
  38 +DECLARE
  39 + parent_author int;
  40 +BEGIN
  41 + IF NEW.replyto IS NOT NULL THEN
  42 + SELECT userid INTO parent_author FROM comments WHERE id = NEW.replyto;
  43 + INSERT INTO user_events (userid, type, private, message_id, comment_id) SELECT memories.userid, 'WATCH', 'f', NEW.topic, NEW.id FROM memories WHERE memories.topic = NEW.topic AND NEW.userid != memories.userid AND memories.userid != parent_author AND NOT EXISTS (SELECT ignore_list.userid FROM ignore_list WHERE ignore_list.userid=memories.userid AND ignored=NEW.userid) AND watch;
  44 + ELSE
  45 + INSERT INTO user_events (userid, type, private, message_id, comment_id) SELECT memories.userid, 'WATCH', 'f', NEW.topic, NEW.id FROM memories WHERE memories.topic = NEW.topic AND NEW.userid != memories.userid AND NOT EXISTS (SELECT ignore_list.userid FROM ignore_list WHERE ignore_list.userid=memories.userid AND ignored=NEW.userid) AND watch;
  46 + END IF;
  47 +
  48 + RETURN NULL;
  49 +END;
  50 +$$;
  51 + </sql>
  52 + </changeSet>
  53 +</databaseChangeLog>

0 comments on commit a5dc423

Please sign in to comment.
Something went wrong with that request. Please try again.