-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nana-EC <nana.essilfie-conduah@hedera.com>
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
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
47 changes: 47 additions & 0 deletions
47
hedera-mirror-importer/src/main/resources/db/migration/v2/V2.0.5__upsert_support.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,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; |