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 INTEGER PRIMARY KEY AUTOINCREMENT, 26 user_name TEXT NOT NULL, 27 profile_tag VARCHAR(32) NOT NULL, 28 kind VARCHAR(8) NOT NULL, 29 app_id VARCHAR(64) NOT NULL, 30 app_display_name VARCHAR(64) NOT NULL, 31 device_display_name VARCHAR(128) NOT NULL, 32 pushkey VARBINARY(512) NOT NULL, 33 ts BIGINT UNSIGNED NOT NULL, 34 lang VARCHAR(8), 35 data LONGBLOB, 36 last_token TEXT, 37 last_success BIGINT UNSIGNED, 38 failing_since BIGINT UNSIGNED, 39 UNIQUE (app_id, pushkey) 40); 41 42CREATE TABLE IF NOT EXISTS push_rules ( 43 id INTEGER PRIMARY KEY AUTOINCREMENT, 44 user_name TEXT NOT NULL, 45 rule_id TEXT NOT NULL, 46 priority_class TINYINT NOT NULL, 47 priority INTEGER NOT NULL DEFAULT 0, 48 conditions TEXT NOT NULL, 49 actions TEXT NOT NULL, 50 UNIQUE(user_name, rule_id) 51); 52 53CREATE INDEX IF NOT EXISTS push_rules_user_name on push_rules (user_name); 54 55CREATE TABLE IF NOT EXISTS user_filters( 56 user_id TEXT, 57 filter_id BIGINT UNSIGNED, 58 filter_json LONGBLOB 59); 60 61CREATE INDEX IF NOT EXISTS user_filters_by_user_id_filter_id ON user_filters( 62 user_id, filter_id 63); 64