Skip to content

Commit

Permalink
Add migration to v2
Browse files Browse the repository at this point in the history
Signed-off-by: Nana-EC <nana.essilfie-conduah@hedera.com>
  • Loading branch information
Nana-EC committed Jun 10, 2021
1 parent ad41a97 commit 485e4d3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ create table if not exists entity
auto_renew_account_id bigint,
auto_renew_period bigint,
created_timestamp bigint,
deleted boolean default false not null,
deleted boolean,
expiration_timestamp bigint,
id bigint not null,
key bytea,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-------------------
-- Support upsert (insert and update from temp table) capabilities for updatable domains
-------------------

-- create getNewAccountFreezeStatus function
-- if no freeze_key return NOT_APPLICABLE (0), else return FROZEN (1) or UNFROZEN (2) based on if freeze_default is true
create or replace function getNewAccountFreezeStatus(tokenId bigint) returns smallint as
$$
declare
key bytea;
freezeDefault boolean;
status smallint;
begin
select into freezeDefault, key freeze_default, freeze_key from token where token_id = tokenId;
if key is null then
status := 0;
else
if freezeDefault then
status := 1;
else
status := 2;
end if;
end if;

return status;
end
$$ language plpgsql;


-- create getNewAccountKycStatus function - takes tokenId and gives KycStatus default
-- if no key_key return NOT_APPLICABLE (0), else return REVOKED (2)
create or replace function getNewAccountKycStatus(tokenId bigint) returns smallint as
$$
declare
key bytea;
status smallint;
begin
select into key kyc_key from token where token_id = tokenId;
if key is null then
status := 0;
else
status := 2;
end if;

return status;
end
$$ language plpgsql;

0 comments on commit 485e4d3

Please sign in to comment.