-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from kaleido-io/psql
Persistence enhancements - including adding PostgreSQL support
- Loading branch information
Showing
114 changed files
with
9,273 additions
and
2,258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,6 @@ linters: | |
disable-all: false | ||
enable: | ||
- bodyclose | ||
- depguard | ||
- dogsled | ||
- errcheck | ||
- goconst | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
db/migrations/postgres/000001_create_transactions_table.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
BEGIN; | ||
DROP INDEX transactions_id; | ||
DROP INDEX transactions_nonce; | ||
DROP TABLE transactions; | ||
COMMIT; |
25 changes: 25 additions & 0 deletions
25
db/migrations/postgres/000001_create_transactions_table.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
BEGIN; | ||
CREATE TABLE transactions ( | ||
seq SERIAL PRIMARY KEY, | ||
id TEXT NOT NULL, | ||
created BIGINT NOT NULL, | ||
updated BIGINT NOT NULL, | ||
status VARCHAR(65) NOT NULL, | ||
delete BIGINT, | ||
tx_from TEXT, | ||
tx_to TEXT, | ||
tx_nonce VARCHAR(65), | ||
tx_gas VARCHAR(65), | ||
tx_value VARCHAR(65), | ||
tx_gasprice TEXT, | ||
tx_data TEXT NOT NULL, | ||
tx_hash TEXT NOT NULL, | ||
policy_info TEXT, | ||
first_submit BIGINT, | ||
last_submit BIGINT, | ||
error_message TEXT NOT NULL | ||
); | ||
CREATE UNIQUE INDEX transactions_id ON transactions(id); | ||
CREATE UNIQUE INDEX transactions_nonce ON transactions(tx_from, tx_nonce); | ||
CREATE INDEX transactions_hash ON transactions(tx_hash); | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
BEGIN; | ||
DROP INDEX receipts_id; | ||
DROP TABLE receipts; | ||
COMMIT; |
16 changes: 16 additions & 0 deletions
16
db/migrations/postgres/000002_create_receipts_table.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
BEGIN; | ||
CREATE TABLE receipts ( | ||
seq SERIAL PRIMARY KEY, | ||
id TEXT NOT NULL, | ||
created BIGINT NOT NULL, | ||
updated BIGINT NOT NULL, | ||
block_number VARCHAR(65), | ||
tx_index VARCHAR(65), | ||
block_hash TEXT NOT NULL, | ||
success BOOLEAN NOT NULL, | ||
protocol_id TEXT NOT NULL, | ||
extra_info TEXT, | ||
contract_loc TEXT | ||
); | ||
CREATE UNIQUE INDEX receipts_id ON receipts(id); | ||
COMMIT; |
5 changes: 5 additions & 0 deletions
5
db/migrations/postgres/000003_create_confirmations_table.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
BEGIN; | ||
DROP INDEX confirmations_id; | ||
DROP INDEX confirmations_txid; | ||
DROP TABLE confirmations; | ||
COMMIT; |
14 changes: 14 additions & 0 deletions
14
db/migrations/postgres/000003_create_confirmations_table.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
BEGIN; | ||
CREATE TABLE confirmations ( | ||
seq SERIAL PRIMARY KEY, | ||
id UUID NOT NULL, | ||
created BIGINT NOT NULL, | ||
updated BIGINT NOT NULL, | ||
tx_id TEXT NOT NULL, | ||
block_number BIGINT NOT NULL, | ||
block_hash TEXT NOT NULL, | ||
parent_hash TEXT NOT NULL | ||
); | ||
CREATE UNIQUE INDEX confirmations_id ON confirmations(id); | ||
CREATE INDEX confirmations_txid ON confirmations(tx_id); | ||
COMMIT; |
5 changes: 5 additions & 0 deletions
5
db/migrations/postgres/000004_create_txhistory_table.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
BEGIN; | ||
DROP INDEX IF EXISTS txhistory_id; | ||
DROP INDEX IF EXISTS txhistory_txid; | ||
DROP TABLE txhistory; | ||
COMMIT; |
15 changes: 15 additions & 0 deletions
15
db/migrations/postgres/000004_create_txhistory_table.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
BEGIN; | ||
CREATE TABLE txhistory ( | ||
seq SERIAL PRIMARY KEY, | ||
id UUID NOT NULL, | ||
time BIGINT NOT NULL, | ||
last_occurrence BIGINT NOT NULL, | ||
tx_id TEXT NOT NULL, | ||
status TEXT NOT NULL, | ||
action TEXT NOT NULL, | ||
count INT NOT NULL, | ||
error TEXT, | ||
error_time BIGINT, | ||
info TEXT | ||
); | ||
COMMIT; |
4 changes: 4 additions & 0 deletions
4
db/migrations/postgres/000005_create_checkpoints_table.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
BEGIN; | ||
DROP INDEX checkpoints_id; | ||
DROP TABLE checkpoints; | ||
COMMIT; |
10 changes: 10 additions & 0 deletions
10
db/migrations/postgres/000005_create_checkpoints_table.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
BEGIN; | ||
CREATE TABLE checkpoints ( | ||
seq SERIAL PRIMARY KEY, | ||
id UUID NOT NULL, | ||
created BIGINT NOT NULL, | ||
updated BIGINT NOT NULL, | ||
listeners JSON | ||
); | ||
CREATE UNIQUE INDEX checkpoints_id ON checkpoints(id); | ||
COMMIT; |
5 changes: 5 additions & 0 deletions
5
db/migrations/postgres/000006_create_eventstreams_table.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
BEGIN; | ||
DROP INDEX eventstreams_id; | ||
DROP INDEX eventstreams_name; | ||
DROP TABLE eventstreams; | ||
COMMIT; |
20 changes: 20 additions & 0 deletions
20
db/migrations/postgres/000006_create_eventstreams_table.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
BEGIN; | ||
CREATE TABLE eventstreams ( | ||
seq SERIAL PRIMARY KEY, | ||
id UUID NOT NULL, | ||
created BIGINT NOT NULL, | ||
updated BIGINT NOT NULL, | ||
name TEXT, | ||
suspended BOOLEAN, | ||
stream_type TEXT, | ||
error_handling TEXT, | ||
batch_size BIGINT, | ||
batch_timeout TEXT NOT NULL, | ||
retry_timeout TEXT NOT NULL, | ||
blocked_retry_timeout TEXT NOT NULL, | ||
webhook_config TEXT, | ||
websocket_config TEXT | ||
); | ||
CREATE UNIQUE INDEX eventstreams_id ON eventstreams(id); | ||
CREATE UNIQUE INDEX eventstreams_name ON eventstreams(name); | ||
COMMIT; |
6 changes: 6 additions & 0 deletions
6
db/migrations/postgres/000007_create_listeners_table.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
BEGIN; | ||
DROP INDEX listeners_id; | ||
DROP INDEX listeners_name; | ||
DROP INDEX listeners_stream; | ||
DROP TABLE listeners; | ||
COMMIT; |
17 changes: 17 additions & 0 deletions
17
db/migrations/postgres/000007_create_listeners_table.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
BEGIN; | ||
CREATE TABLE listeners ( | ||
seq SERIAL PRIMARY KEY, | ||
id UUID NOT NULL, | ||
created BIGINT NOT NULL, | ||
updated BIGINT NOT NULL, | ||
name TEXT, | ||
stream_id UUID NOT NULL, | ||
filters TEXT, | ||
options TEXT, | ||
signature TEXT, | ||
from_block TEXT | ||
); | ||
CREATE UNIQUE INDEX listeners_id ON listeners(id); | ||
CREATE UNIQUE INDEX listeners_name ON listeners(name); -- global uniqueness on names | ||
CREATE INDEX listeners_stream ON listeners(stream_id); | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
BEGIN; | ||
DROP INDEX IF EXISTS txhistory_id; | ||
DROP INDEX IF EXISTS txhistory_txid; | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
BEGIN; | ||
-- Allow nil data on transactions, for example for a simple transfer operation | ||
ALTER TABLE transactions ALTER COLUMN tx_data DROP NOT NULL; | ||
|
||
-- Correct TXHistory indexes if created by an invalid 000004 migration (no longer in codebase). | ||
DROP INDEX IF EXISTS txhistory_id; | ||
DROP INDEX IF EXISTS txhistory_txid; | ||
|
||
-- Create corrected TXHistory indexes | ||
CREATE UNIQUE INDEX txhistory_id ON txhistory(id); | ||
CREATE INDEX txhistory_txid ON txhistory(tx_id); | ||
COMMIT; |
Oops, something went wrong.