Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved to new sql structure #321

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend-rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend-rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "concordium-scan"
version = "0.1.4"
version = "0.1.5"
edition = "2021"
description = "CCDScan: Indexer and API for the Concordium blockchain"
authors = ["Concordium <[email protected]>"]
Expand Down
25 changes: 0 additions & 25 deletions backend-rust/migrations/0001_initialize.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -373,31 +373,6 @@ CREATE INDEX event_index_per_contract_idx ON contract_events (event_index_per_co
-- Important for quickly filtering contract events by a specific contract.
CREATE INDEX contract_events_idx ON contract_events (contract_index, contract_sub_index);

CREATE OR REPLACE FUNCTION account_updated_notify_trigger_function() RETURNS trigger AS $trigger$
DECLARE
rec affected_accounts;
lookup_result TEXT;
BEGIN
CASE TG_OP
WHEN 'INSERT' THEN
-- Lookup the account address associated with the account index.
SELECT address
INTO lookup_result
FROM accounts
WHERE index = NEW.account_index;

-- Include the lookup result in the payload
PERFORM pg_notify('account_updated', lookup_result);
ELSE NULL;
END CASE;
RETURN NEW;
END;
$trigger$ LANGUAGE plpgsql;

CREATE TRIGGER account_updated_notify_trigger AFTER INSERT
ON affected_accounts
FOR EACH ROW EXECUTE PROCEDURE account_updated_notify_trigger_function();

CREATE OR REPLACE FUNCTION block_added_notify_trigger_function() RETURNS trigger AS $trigger$
DECLARE
rec blocks;
Expand Down
1 change: 1 addition & 0 deletions backend-rust/migrations/0002_account_notify.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- Add down migration script here
24 changes: 24 additions & 0 deletions backend-rust/migrations/0002_account_notify.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
CREATE OR REPLACE FUNCTION account_updated_notify_trigger_function() RETURNS trigger AS $trigger$
DECLARE
rec affected_accounts;
lookup_result TEXT;
BEGIN
CASE TG_OP
WHEN 'INSERT' THEN
-- Lookup the account address associated with the account index.
SELECT address
INTO lookup_result
FROM accounts
WHERE index = NEW.account_index;

-- Include the lookup result in the payload
PERFORM pg_notify('account_updated', lookup_result);
ELSE NULL;
END CASE;
RETURN NEW;
END;
$trigger$ LANGUAGE plpgsql;

CREATE TRIGGER account_updated_notify_trigger AFTER INSERT
ON affected_accounts
FOR EACH ROW EXECUTE PROCEDURE account_updated_notify_trigger_function();
Loading