1/* Copyright 2015, 2016 OpenMarket Ltd 2 * 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 16CREATE TABLE IF NOT EXISTS rejections( 17 event_id TEXT NOT NULL, 18 reason TEXT NOT NULL, 19 last_check TEXT NOT NULL, 20 UNIQUE (event_id) 21); 22 23-- Push notification endpoints that users have configured 24CREATE TABLE IF NOT EXISTS pushers ( 25 id BIGINT PRIMARY KEY, 26 user_name TEXT NOT NULL, 27 access_token BIGINT DEFAULT NULL, 28 profile_tag VARCHAR(32) NOT NULL, 29 kind VARCHAR(8) NOT NULL, 30 app_id VARCHAR(64) NOT NULL, 31 app_display_name VARCHAR(64) NOT NULL, 32 device_display_name VARCHAR(128) NOT NULL, 33 pushkey bytea NOT NULL, 34 ts BIGINT NOT NULL, 35 lang VARCHAR(8), 36 data bytea, 37 last_token TEXT, 38 last_success BIGINT, 39 failing_since BIGINT, 40 UNIQUE (app_id, pushkey) 41); 42 43CREATE TABLE IF NOT EXISTS push_rules ( 44 id BIGINT PRIMARY KEY, 45 user_name TEXT NOT NULL, 46 rule_id TEXT NOT NULL, 47 priority_class SMALLINT NOT NULL, 48 priority INTEGER NOT NULL DEFAULT 0, 49 conditions TEXT NOT NULL, 50 actions TEXT NOT NULL, 51 UNIQUE(user_name, rule_id) 52); 53 54CREATE INDEX push_rules_user_name on push_rules (user_name); 55 56CREATE TABLE IF NOT EXISTS user_filters( 57 user_id TEXT, 58 filter_id BIGINT, 59 filter_json bytea 60); 61 62CREATE INDEX user_filters_by_user_id_filter_id ON user_filters( 63 user_id, filter_id 64); 65 66CREATE TABLE IF NOT EXISTS push_rules_enable ( 67 id BIGINT PRIMARY KEY, 68 user_name TEXT NOT NULL, 69 rule_id TEXT NOT NULL, 70 enabled SMALLINT, 71 UNIQUE(user_name, rule_id) 72); 73 74CREATE INDEX push_rules_enable_user_name on push_rules_enable (user_name); 75