2016-01-06 21:26:29 -07:00
|
|
|
/* Copyright 2014-2016 OpenMarket Ltd
|
2015-04-10 03:05:44 -06:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
-- Stores what transaction ids we have received and what our response was
|
|
|
|
CREATE TABLE IF NOT EXISTS received_transactions(
|
2015-04-28 05:41:33 -06:00
|
|
|
transaction_id TEXT,
|
|
|
|
origin TEXT,
|
2015-04-14 06:53:20 -06:00
|
|
|
ts BIGINT,
|
2015-04-10 03:05:44 -06:00
|
|
|
response_code INTEGER,
|
2015-04-14 06:53:20 -06:00
|
|
|
response_json bytea,
|
|
|
|
has_been_referenced smallint default 0, -- Whether thishas been referenced by a prev_tx
|
2015-04-10 03:05:44 -06:00
|
|
|
UNIQUE (transaction_id, origin)
|
|
|
|
);
|
|
|
|
|
2015-04-14 06:53:20 -06:00
|
|
|
CREATE INDEX transactions_have_ref ON received_transactions(origin, has_been_referenced);-- WHERE has_been_referenced = 0;
|
2015-04-10 03:05:44 -06:00
|
|
|
|
|
|
|
-- For sent transactions only.
|
|
|
|
CREATE TABLE IF NOT EXISTS transaction_id_to_pdu(
|
|
|
|
transaction_id INTEGER,
|
2015-04-28 05:41:33 -06:00
|
|
|
destination TEXT,
|
|
|
|
pdu_id TEXT,
|
|
|
|
pdu_origin TEXT,
|
2015-04-10 03:05:44 -06:00
|
|
|
UNIQUE (transaction_id, destination)
|
|
|
|
);
|
|
|
|
|
2015-04-14 06:53:20 -06:00
|
|
|
CREATE INDEX transaction_id_to_pdu_dest ON transaction_id_to_pdu(destination);
|
2015-04-10 03:05:44 -06:00
|
|
|
|
|
|
|
-- To track destination health
|
|
|
|
CREATE TABLE IF NOT EXISTS destinations(
|
2015-04-28 05:41:33 -06:00
|
|
|
destination TEXT PRIMARY KEY,
|
2015-04-14 06:53:20 -06:00
|
|
|
retry_last_ts BIGINT,
|
2015-04-10 03:05:44 -06:00
|
|
|
retry_interval INTEGER
|
|
|
|
);
|