Skip to content

Commit

Permalink
Merge pull request #332 from Concordium/merge-migration
Browse files Browse the repository at this point in the history
Merge the two sql migration files
  • Loading branch information
limemloh authored Dec 18, 2024
2 parents 8c336d5 + 02ddf86 commit 9fd5af1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
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.

0 comments on commit 9fd5af1

Please sign in to comment.