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

Merge the two sql migration files #332

Merged
merged 1 commit into from
Dec 18, 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
25 changes: 25 additions & 0 deletions backend-rust/migrations/0001_initialize.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,28 @@ $trigger$ LANGUAGE plpgsql;
CREATE TRIGGER block_added_notify_trigger AFTER INSERT
ON blocks
FOR EACH ROW EXECUTE PROCEDURE block_added_notify_trigger_function();

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();
1 change: 0 additions & 1 deletion backend-rust/migrations/0002_account_notify.down.sql

This file was deleted.

24 changes: 0 additions & 24 deletions backend-rust/migrations/0002_account_notify.up.sql

This file was deleted.

Loading