-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDP-1001] Move all TSS-related tables to the tss schema (#141)
### What Move all TSS-related tables to the tss schema. ### Why Close https://stellarorg.atlassian.net/browse/SDP-1001.
- Loading branch information
1 parent
23927cb
commit 70cd0fb
Showing
31 changed files
with
326 additions
and
148 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
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
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
67 changes: 67 additions & 0 deletions
67
db/migrations/sdp-migrations/2024-01-03.0-drop-submitter-transactions-table.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,67 @@ | ||
-- +migrate Up | ||
|
||
DROP TRIGGER refresh_submitter_transactions_updated_at ON submitter_transactions; | ||
|
||
DROP TABLE submitter_transactions; | ||
|
||
DROP FUNCTION create_submitter_transactions_status_history; | ||
|
||
DROP TYPE transaction_status; | ||
|
||
|
||
-- +migrate Down | ||
|
||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | ||
|
||
CREATE TYPE transaction_status AS ENUM ('PENDING', 'PROCESSING', 'SUCCESS', 'ERROR'); | ||
|
||
-- +migrate StatementBegin | ||
CREATE OR REPLACE FUNCTION create_submitter_transactions_status_history(time_stamp TIMESTAMP WITH TIME ZONE, tss_status transaction_status, status_message VARCHAR, stellar_transaction_hash TEXT, xdr_sent TEXT, xdr_received TEXT) | ||
RETURNS jsonb AS $$ | ||
BEGIN | ||
RETURN json_build_object( | ||
'timestamp', time_stamp, | ||
'status', tss_status, | ||
'status_message', status_message, | ||
'stellar_transaction_hash', stellar_transaction_hash, | ||
'xdr_sent', xdr_sent, | ||
'xdr_received', xdr_received | ||
); | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
-- +migrate StatementEnd | ||
|
||
CREATE TABLE submitter_transactions ( | ||
id VARCHAR(36) PRIMARY KEY DEFAULT public.uuid_generate_v4(), | ||
external_id VARCHAR(64) NOT NULL, | ||
|
||
status transaction_status NOT NULL DEFAULT 'PENDING'::transaction_status, | ||
status_history jsonb[] NULL DEFAULT ARRAY[create_submitter_transactions_status_history(NOW(), 'PENDING', NULL, NULL, NULL, NULL)], | ||
status_message TEXT NULL, | ||
|
||
asset_code VARCHAR(12) NOT NULL, | ||
asset_issuer VARCHAR(56) NOT NULL, | ||
amount NUMERIC(10,7) NOT NULL, | ||
destination VARCHAR(56) NOT NULL, | ||
|
||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
locked_at TIMESTAMPTZ, | ||
started_at TIMESTAMPTZ, | ||
sent_at TIMESTAMPTZ, | ||
completed_at TIMESTAMPTZ, | ||
synced_at TIMESTAMPTZ, | ||
locked_until_ledger_number INTEGER, | ||
|
||
stellar_transaction_hash VARCHAR(64) UNIQUE, | ||
attempts_count integer DEFAULT 0 CHECK (attempts_count >= 0), | ||
xdr_sent TEXT UNIQUE, | ||
xdr_received TEXT UNIQUE, | ||
|
||
CONSTRAINT asset_issuer_length_check CHECK ((asset_code = 'XLM' AND char_length(asset_issuer) = 0) OR char_length(asset_issuer) = 56) | ||
); | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS idx_unique_external_id ON submitter_transactions (external_id) WHERE status != 'ERROR'; | ||
|
||
-- TRIGGER: updated_at | ||
CREATE TRIGGER refresh_submitter_transactions_updated_at BEFORE UPDATE ON submitter_transactions FOR EACH ROW EXECUTE PROCEDURE update_at_refresh(); |
20 changes: 20 additions & 0 deletions
20
db/migrations/sdp-migrations/2024-01-03.1-drop-channel-accounts-table.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 @@ | ||
-- +migrate Up | ||
|
||
DROP TRIGGER refresh_channel_accounts_updated_at ON channel_accounts; | ||
|
||
DROP TABLE channel_accounts; | ||
|
||
|
||
-- +migrate Down | ||
|
||
CREATE TABLE channel_accounts ( | ||
public_key VARCHAR(64) PRIMARY KEY, | ||
private_key VARCHAR(256), | ||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), | ||
locked_at TIMESTAMPTZ, | ||
locked_until_ledger_number INTEGER | ||
); | ||
|
||
-- TRIGGER: updated_at | ||
CREATE TRIGGER refresh_channel_accounts_updated_at BEFORE UPDATE ON channel_accounts FOR EACH ROW EXECUTE PROCEDURE update_at_refresh(); |
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
Oops, something went wrong.