diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d1555f2f..ddff77e3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ Release built: _not released yet_ - Brand-new `two_way_linked_*` properties on the `details` property of the Resources, Accounts, Packages and other global entities. - See https://docs.radixdlt.com/docs/metadata-for-verification#metadata-standards-for-verification-of-onledger-entities for detailed specification. - Added support for the Native Resource Details in the `/state/entity/details` endpoint, returned when the `native_resource_details` opt-in is enabled. - - Brand-new `native_resource_details` property on the `details` property. + - Introduced a new `native_resource_details` property on the `details` object when looking up fungible or non-fungible resource entities with the entity details endpoint. This property is present when the resource has a special meaning to native blueprints, and gives extra information about the resource. For example, it identifies pool units with their linked pool, and gives the redemption value for a single unit. - Includes **unit** redemption value for the Validator LSU token and the unit tokens of various Pools. - Added new endpoint `/extensions/resource-holders/page` which returns information about all holders of the queried resource. diff --git a/src/RadixDlt.NetworkGateway.Abstractions/Model/EntityRelationship.cs b/src/RadixDlt.NetworkGateway.Abstractions/Model/EntityRelationship.cs index 18ab5bab1..e1b142d6d 100644 --- a/src/RadixDlt.NetworkGateway.Abstractions/Model/EntityRelationship.cs +++ b/src/RadixDlt.NetworkGateway.Abstractions/Model/EntityRelationship.cs @@ -83,7 +83,7 @@ public enum EntityRelationship ValidatorToLockedOwnerStakeUnitVault, ValidatorToPendingOwnerStakeUnitUnlockVault, - StakeVaultOfValidator, + StakeUnitOfValidator, ClaimTokenOfValidator, // Account Lockers (used on related Vaults and KeyValueStores) @@ -97,7 +97,7 @@ public enum EntityRelationship ResourcePoolToResource, ResourcePoolToResourceVault, - UnitVaultOfResourcePool, + UnitResourceOfResourcePool, ResourceVaultOfResourcePool, // Access Controllers diff --git a/src/RadixDlt.NetworkGateway.Abstractions/Numerics/TokenAmount.cs b/src/RadixDlt.NetworkGateway.Abstractions/Numerics/TokenAmount.cs index 4a4bb8ca4..123e8c425 100644 --- a/src/RadixDlt.NetworkGateway.Abstractions/Numerics/TokenAmount.cs +++ b/src/RadixDlt.NetworkGateway.Abstractions/Numerics/TokenAmount.cs @@ -74,7 +74,6 @@ namespace RadixDlt.NetworkGateway.Abstractions.Numerics; public static readonly TokenAmount Zero; public static readonly TokenAmount NaN; - public static readonly TokenAmount OneFullUnit; public static readonly TokenAmount MaxValue; private const int DecimalPrecision = 18; @@ -84,10 +83,10 @@ namespace RadixDlt.NetworkGateway.Abstractions.Numerics; static TokenAmount() { _divisor = BigInteger.Pow(10, DecimalPrecision); + MaxValue = new TokenAmount(BigInteger.Pow(2, 192), 0); Zero = new TokenAmount(0); NaN = new TokenAmount(true); - OneFullUnit = new TokenAmount(_divisor); } private readonly BigInteger _subUnits; @@ -155,9 +154,9 @@ public static TokenAmount FromDecimalString(string decimalString) public static TokenAmount operator -(TokenAmount a, TokenAmount b) => (a.IsNaN() || b.IsNaN()) ? NaN : new TokenAmount(a._subUnits - b._subUnits); - public static TokenAmount operator *(TokenAmount a, TokenAmount b) => (a.IsNaN() || b.IsNaN()) ? NaN : new TokenAmount(a._subUnits * b._subUnits); + public static TokenAmount operator *(TokenAmount a, TokenAmount b) => (a.IsNaN() || b.IsNaN()) ? NaN : new TokenAmount((a._subUnits * b._subUnits) / _divisor); - public static TokenAmount operator /(TokenAmount a, TokenAmount b) => (a.IsNaN() || b.IsNaN()) ? NaN : Divide(a, b); + public static TokenAmount operator /(TokenAmount a, TokenAmount b) => (a.IsNaN() || b.IsNaN() || b == Zero) ? NaN : new TokenAmount((a._subUnits * _divisor) / b._subUnits); // ReSharper disable SimplifyConditionalTernaryExpression - As it's clearer as written #pragma warning disable IDE0075 @@ -270,42 +269,4 @@ public int CompareTo(TokenAmount other) var isNaNComparison = _isNaN.CompareTo(other._isNaN); return isNaNComparison != 0 ? isNaNComparison : _subUnits.CompareTo(other._subUnits); } - - // Heavily inspired by https://www.codeproject.com/Articles/5366079/BigDecimal-in-Csharp - // Licensed under CPOL: https://en.wikipedia.org/wiki/Code_Project_Open_License - // Author: Paulo Francisco Zemek. August, 01, 2023. - private static TokenAmount Divide(TokenAmount dividend, TokenAmount divisor) - { - if (divisor == Zero) - { - // This rule might look odd, but when simplifying expressions, x/x (x divided by x) is 1. - // So, to keep the rule true, 0 divided by 0 is also 1. - if (dividend == Zero) - { - return OneFullUnit; - } - - throw new DivideByZeroException($"{nameof(divisor)} can only be zero if {nameof(dividend)} is zero."); - } - - var doublePrecisionDividendSubUnits = dividend._subUnits * _divisor; - var divisorSubUnits = divisor._subUnits; - - return FromSubUnits(doublePrecisionDividendSubUnits / divisorSubUnits); - } - - // Is there a faster approach that works with BigIntegers? - // It seems Log10 isn't faster at all. - private static int CountDigits(BigInteger value) - { - int count = 0; - - while (value > 0) - { - count++; - value /= 10; - } - - return count; - } } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/RelationshipProcessor.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/RelationshipProcessor.cs index 0d817f355..0af2f2f62 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/RelationshipProcessor.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/RelationshipProcessor.cs @@ -123,7 +123,7 @@ public void ScanUpsert(CoreModel.Substate substateData, ReferencedEntity referen _referencedEntities.Get((EntityAddress)validator.Value.StakeUnitResourceAddress).PostResolveConfigureLow((ResourceEntity ue) => { - ue.AddCorrelation(EntityRelationship.StakeVaultOfValidator, e.Id); + ue.AddCorrelation(EntityRelationship.StakeUnitOfValidator, e.Id); }); }); } @@ -153,7 +153,7 @@ public void ScanUpsert(CoreModel.Substate substateData, ReferencedEntity referen _referencedEntities.GetByDatabaseId(poolUnitResourceEntity.DatabaseId).PostResolveConfigureLow((ResourceEntity ue) => { - ue.AddCorrelation(EntityRelationship.UnitVaultOfResourcePool, e.Id); + ue.AddCorrelation(EntityRelationship.UnitResourceOfResourcePool, e.Id); }); var vault = oneResourcePool.Value.Vault; @@ -180,7 +180,7 @@ public void ScanUpsert(CoreModel.Substate substateData, ReferencedEntity referen _referencedEntities.GetByDatabaseId(poolUnitResourceEntity.DatabaseId).PostResolveConfigureLow((ResourceEntity ue) => { - ue.AddCorrelation(EntityRelationship.UnitVaultOfResourcePool, e.Id); + ue.AddCorrelation(EntityRelationship.UnitResourceOfResourcePool, e.Id); }); foreach (var poolVault in twoResourcePool.Value.Vaults) @@ -206,7 +206,7 @@ public void ScanUpsert(CoreModel.Substate substateData, ReferencedEntity referen _referencedEntities.GetByDatabaseId(poolUnitResourceEntity.DatabaseId).PostResolveConfigureLow((ResourceEntity ue) => { - ue.AddCorrelation(EntityRelationship.UnitVaultOfResourcePool, e.Id); + ue.AddCorrelation(EntityRelationship.UnitResourceOfResourcePool, e.Id); }); foreach (var vault in multiResourcePool.Value.Vaults) diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.Designer.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240819084018_InitialCreate.Designer.cs similarity index 99% rename from src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.Designer.cs rename to src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240819084018_InitialCreate.Designer.cs index 479937d46..1608e993f 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.Designer.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240819084018_InitialCreate.Designer.cs @@ -62,7 +62,7 @@ * permissions under this License. */ -// +// using System; using System.Collections.Generic; using System.Numerics; @@ -81,7 +81,7 @@ namespace RadixDlt.NetworkGateway.PostgresIntegration.Migrations { [DbContext(typeof(MigrationsDbContext))] - [Migration("20240816104539_InitialCreate")] + [Migration("20240819084018_InitialCreate")] partial class InitialCreate { /// @@ -95,7 +95,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "account_default_deposit_rule", new[] { "accept", "reject", "allow_existing" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "account_resource_preference_rule", new[] { "allowed", "disallowed" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "authorized_depositor_badge_type", new[] { "resource", "non_fungible" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_relationship", new[] { "component_to_instantiating_package", "vault_to_resource", "royalty_vault_of_component", "validator_to_stake_vault", "validator_to_pending_xrd_withdraw_vault", "validator_to_locked_owner_stake_unit_vault", "validator_to_pending_owner_stake_unit_unlock_vault", "stake_vault_of_validator", "claim_token_of_validator", "account_locker_of_locker", "account_locker_of_account", "resource_pool_to_unit_resource", "resource_pool_to_resource", "resource_pool_to_resource_vault", "unit_vault_of_resource_pool", "resource_vault_of_resource_pool", "access_controller_to_recovery_badge", "recovery_badge_of_access_controller" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_relationship", new[] { "component_to_instantiating_package", "vault_to_resource", "royalty_vault_of_component", "validator_to_stake_vault", "validator_to_pending_xrd_withdraw_vault", "validator_to_locked_owner_stake_unit_vault", "validator_to_pending_owner_stake_unit_unlock_vault", "stake_unit_of_validator", "claim_token_of_validator", "account_locker_of_locker", "account_locker_of_account", "resource_pool_to_unit_resource", "resource_pool_to_resource", "resource_pool_to_resource_vault", "unit_resource_of_resource_pool", "resource_vault_of_resource_pool", "access_controller_to_recovery_badge", "recovery_badge_of_access_controller" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "global_consensus_manager", "global_fungible_resource", "global_non_fungible_resource", "global_generic_component", "internal_generic_component", "global_account_component", "global_package", "internal_key_value_store", "internal_fungible_vault", "internal_non_fungible_vault", "global_validator", "global_access_controller", "global_identity", "global_one_resource_pool", "global_two_resource_pool", "global_multi_resource_pool", "global_transaction_tracker", "global_account_locker" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_manifest_class", new[] { "general", "transfer", "validator_stake", "validator_unstake", "validator_claim", "account_deposit_settings_update", "pool_contribution", "pool_redemption" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_event_type", new[] { "withdrawal", "deposit" }); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240819084018_InitialCreate.cs similarity index 99% rename from src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.cs rename to src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240819084018_InitialCreate.cs index b0598805d..be8617b0c 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240819084018_InitialCreate.cs @@ -62,7 +62,7 @@ * permissions under this License. */ -using System; +using System; using System.Collections.Generic; using System.Numerics; using Microsoft.EntityFrameworkCore.Migrations; @@ -85,7 +85,7 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:Enum:account_default_deposit_rule", "accept,reject,allow_existing") .Annotation("Npgsql:Enum:account_resource_preference_rule", "allowed,disallowed") .Annotation("Npgsql:Enum:authorized_depositor_badge_type", "resource,non_fungible") - .Annotation("Npgsql:Enum:entity_relationship", "component_to_instantiating_package,vault_to_resource,royalty_vault_of_component,validator_to_stake_vault,validator_to_pending_xrd_withdraw_vault,validator_to_locked_owner_stake_unit_vault,validator_to_pending_owner_stake_unit_unlock_vault,stake_vault_of_validator,claim_token_of_validator,account_locker_of_locker,account_locker_of_account,resource_pool_to_unit_resource,resource_pool_to_resource,resource_pool_to_resource_vault,unit_vault_of_resource_pool,resource_vault_of_resource_pool,access_controller_to_recovery_badge,recovery_badge_of_access_controller") + .Annotation("Npgsql:Enum:entity_relationship", "component_to_instantiating_package,vault_to_resource,royalty_vault_of_component,validator_to_stake_vault,validator_to_pending_xrd_withdraw_vault,validator_to_locked_owner_stake_unit_vault,validator_to_pending_owner_stake_unit_unlock_vault,stake_unit_of_validator,claim_token_of_validator,account_locker_of_locker,account_locker_of_account,resource_pool_to_unit_resource,resource_pool_to_resource,resource_pool_to_resource_vault,unit_resource_of_resource_pool,resource_vault_of_resource_pool,access_controller_to_recovery_badge,recovery_badge_of_access_controller") .Annotation("Npgsql:Enum:entity_type", "global_consensus_manager,global_fungible_resource,global_non_fungible_resource,global_generic_component,internal_generic_component,global_account_component,global_package,internal_key_value_store,internal_fungible_vault,internal_non_fungible_vault,global_validator,global_access_controller,global_identity,global_one_resource_pool,global_two_resource_pool,global_multi_resource_pool,global_transaction_tracker,global_account_locker") .Annotation("Npgsql:Enum:ledger_transaction_manifest_class", "general,transfer,validator_stake,validator_unstake,validator_claim,account_deposit_settings_update,pool_contribution,pool_redemption") .Annotation("Npgsql:Enum:ledger_transaction_marker_event_type", "withdrawal,deposit") diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql index 09a1d8d8e..51e4c956f 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql @@ -9,11 +9,11 @@ START TRANSACTION; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TYPE account_default_deposit_rule AS ENUM ('accept', 'reject', 'allow_existing'); CREATE TYPE account_resource_preference_rule AS ENUM ('allowed', 'disallowed'); CREATE TYPE authorized_depositor_badge_type AS ENUM ('resource', 'non_fungible'); - CREATE TYPE entity_relationship AS ENUM ('component_to_instantiating_package', 'vault_to_resource', 'royalty_vault_of_component', 'validator_to_stake_vault', 'validator_to_pending_xrd_withdraw_vault', 'validator_to_locked_owner_stake_unit_vault', 'validator_to_pending_owner_stake_unit_unlock_vault', 'stake_vault_of_validator', 'claim_token_of_validator', 'account_locker_of_locker', 'account_locker_of_account', 'resource_pool_to_unit_resource', 'resource_pool_to_resource', 'resource_pool_to_resource_vault', 'unit_vault_of_resource_pool', 'resource_vault_of_resource_pool', 'access_controller_to_recovery_badge', 'recovery_badge_of_access_controller'); + CREATE TYPE entity_relationship AS ENUM ('component_to_instantiating_package', 'vault_to_resource', 'royalty_vault_of_component', 'validator_to_stake_vault', 'validator_to_pending_xrd_withdraw_vault', 'validator_to_locked_owner_stake_unit_vault', 'validator_to_pending_owner_stake_unit_unlock_vault', 'stake_unit_of_validator', 'claim_token_of_validator', 'account_locker_of_locker', 'account_locker_of_account', 'resource_pool_to_unit_resource', 'resource_pool_to_resource', 'resource_pool_to_resource_vault', 'unit_resource_of_resource_pool', 'resource_vault_of_resource_pool', 'access_controller_to_recovery_badge', 'recovery_badge_of_access_controller'); CREATE TYPE entity_type AS ENUM ('global_consensus_manager', 'global_fungible_resource', 'global_non_fungible_resource', 'global_generic_component', 'internal_generic_component', 'global_account_component', 'global_package', 'internal_key_value_store', 'internal_fungible_vault', 'internal_non_fungible_vault', 'global_validator', 'global_access_controller', 'global_identity', 'global_one_resource_pool', 'global_two_resource_pool', 'global_multi_resource_pool', 'global_transaction_tracker', 'global_account_locker'); CREATE TYPE ledger_transaction_manifest_class AS ENUM ('general', 'transfer', 'validator_stake', 'validator_unstake', 'validator_claim', 'account_deposit_settings_update', 'pool_contribution', 'pool_redemption'); CREATE TYPE ledger_transaction_marker_event_type AS ENUM ('withdrawal', 'deposit'); @@ -37,7 +37,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE account_authorized_depositor_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -50,7 +50,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE account_authorized_depositor_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -66,7 +66,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE account_default_deposit_rule_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -79,7 +79,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE account_locker_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -93,7 +93,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE account_locker_entry_resource_vault_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -107,7 +107,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE account_locker_entry_touch_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -119,7 +119,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE account_resource_preference_rule_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -132,7 +132,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE account_resource_preference_rule_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -147,7 +147,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE component_method_royalty_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -160,7 +160,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE component_method_royalty_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -175,7 +175,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE entities ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -201,7 +201,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE entity_metadata_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -214,7 +214,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE entity_metadata_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -230,7 +230,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE entity_resource_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -246,7 +246,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE entity_resource_aggregated_vaults_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -262,7 +262,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE entity_resource_vault_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -276,7 +276,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE entity_role_assignments_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -290,7 +290,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE entity_role_assignments_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -306,7 +306,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE entity_role_assignments_owner_role_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -319,7 +319,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE entity_vault_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -338,7 +338,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE key_value_store_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -351,7 +351,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE key_value_store_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -366,7 +366,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE key_value_store_schema_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -386,7 +386,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE ledger_transaction_markers ( id bigint GENERATED BY DEFAULT AS IDENTITY, state_version bigint NOT NULL, @@ -406,7 +406,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE ledger_transactions ( state_version bigint NOT NULL, epoch bigint NOT NULL, @@ -454,7 +454,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE non_fungible_id_data_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -469,7 +469,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE non_fungible_id_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -482,7 +482,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE non_fungible_id_location_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -495,7 +495,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE non_fungible_schema_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -511,7 +511,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE package_blueprint_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -524,7 +524,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE package_blueprint_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -544,7 +544,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE package_code_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -557,7 +557,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE package_code_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -573,7 +573,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE pending_transactions ( id bigint GENERATED BY DEFAULT AS IDENTITY, payload_hash text NOT NULL, @@ -601,7 +601,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE resource_entity_supply_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -616,7 +616,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE resource_holders ( id bigint GENERATED BY DEFAULT AS IDENTITY, entity_id bigint NOT NULL, @@ -630,7 +630,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE schema_entry_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -643,7 +643,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE schema_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -657,7 +657,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE state_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -676,7 +676,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE unverified_standard_metadata_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -689,7 +689,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE unverified_standard_metadata_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -706,7 +706,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE validator_cumulative_emission_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -722,7 +722,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE validator_public_key_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -736,7 +736,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE pending_transaction_payloads ( id bigint GENERATED BY DEFAULT AS IDENTITY, pending_transaction_id bigint, @@ -749,7 +749,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE TABLE validator_active_set_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -764,520 +764,520 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_aggregate_history_account_enti~" ON account_authorized_depositor_aggregate_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_~1" ON account_authorized_depositor_entry_history (account_entity_id, resource_entity_id, non_fungible_id, from_state_version) WHERE discriminator = 'non_fungible'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_~2" ON account_authorized_depositor_entry_history (account_entity_id, resource_entity_id, from_state_version) WHERE discriminator = 'resource'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_i~" ON account_authorized_depositor_entry_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_account_default_deposit_rule_history_account_entity_id_from~" ON account_default_deposit_rule_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE UNIQUE INDEX "IX_account_locker_entry_definition_account_locker_entity_id_ac~" ON account_locker_entry_definition (account_locker_entity_id, account_entity_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE UNIQUE INDEX "IX_account_locker_entry_resource_vault_definition_account_lock~" ON account_locker_entry_resource_vault_definition (account_locker_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_account_locker_entry_touch_history_account_locker_definitio~" ON account_locker_entry_touch_history (account_locker_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_account_resource_preference_rule_aggregate_history_account_~" ON account_resource_preference_rule_aggregate_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_account_resource_preference_rule_entry_history_account_enti~" ON account_resource_preference_rule_entry_history (account_entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_aggregate_history_entity_id_from_s~" ON component_method_royalty_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_entry_history_entity_id_from_state~" ON component_method_royalty_entry_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_entry_history_entity_id_method_nam~" ON component_method_royalty_entry_history (entity_id, method_name, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE UNIQUE INDEX "IX_entities_address" ON entities (address); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entities_from_state_version" ON entities (from_state_version) WHERE discriminator = 'global_validator'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_metadata_aggregate_history_entity_id_from_state_vers~" ON entity_metadata_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_metadata_history_entity_id_key_from_state_version" ON entity_metadata_history (entity_id, key, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_resource_aggregate_history_entity_id_from_state_vers~" ON entity_resource_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_resource_aggregated_vaults_history_entity_id_resourc~" ON entity_resource_aggregated_vaults_history (entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_resource_vault_aggregate_history_entity_id_resource_~" ON entity_resource_vault_aggregate_history (entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_aggregate_history_entity_id_from_st~" ON entity_role_assignments_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_entry_history_entity_id_key_role_ke~" ON entity_role_assignments_entry_history (entity_id, key_role, key_module, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_owner_role_history_entity_id_from_s~" ON entity_role_assignments_owner_role_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_global_entity_id_from_state_version" ON entity_vault_history (global_entity_id, from_state_version) WHERE is_royalty_vault = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_global_entity_id_vault_entity_id_from_~" ON entity_vault_history (global_entity_id, vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_id_resource_entity_id_from_state_versi~" ON entity_vault_history (id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_owner_entity_id_from_state_version" ON entity_vault_history (owner_entity_id, from_state_version) WHERE is_royalty_vault = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_owner_entity_id_vault_entity_id_from_s~" ON entity_vault_history (owner_entity_id, vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_vault_entity_id_from_state_version" ON entity_vault_history (vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_definition_key_value_store_entity_id_~" ON key_value_store_entry_definition (key_value_store_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_definition_key_value_store_entity_id~1" ON key_value_store_entry_definition (key_value_store_entity_id, key); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_history_key_value_store_entry_definit~" ON key_value_store_entry_history (key_value_store_entry_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_key_value_store_schema_history_key_value_store_entity_id_fr~" ON key_value_store_schema_history (key_value_store_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_entity_id_state_version" ON ledger_transaction_markers (entity_id, state_version) WHERE discriminator = 'event_global_emitter'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_entity_id_state_version1" ON ledger_transaction_markers (entity_id, state_version) WHERE discriminator = 'affected_global_entity'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_event_type_entity_id_state_versi~" ON ledger_transaction_markers (event_type, entity_id, state_version) WHERE discriminator = 'event'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_manifest_class" ON ledger_transaction_markers (manifest_class, state_version) WHERE discriminator = 'manifest_class'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_manifest_class_is_most_specific" ON ledger_transaction_markers (manifest_class, state_version) WHERE discriminator = 'manifest_class' and is_most_specific = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_operation_type_entity_id_state_v~" ON ledger_transaction_markers (operation_type, entity_id, state_version) WHERE discriminator = 'manifest_address'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_origin_type_state_version" ON ledger_transaction_markers (origin_type, state_version) WHERE discriminator = 'origin'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_state_version" ON ledger_transaction_markers (state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE UNIQUE INDEX "IX_ledger_transactions_epoch_round_in_epoch" ON ledger_transactions (epoch, round_in_epoch) WHERE index_in_round = 0; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_ledger_transactions_intent_hash" ON ledger_transactions USING hash (intent_hash) WHERE intent_hash IS NOT NULL; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_ledger_transactions_round_timestamp" ON ledger_transactions (round_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_data_history_non_fungible_id_definition_id_~" ON non_fungible_id_data_history (non_fungible_id_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_definition_non_fungible_resource_entity_id_~" ON non_fungible_id_definition (non_fungible_resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE UNIQUE INDEX "IX_non_fungible_id_definition_non_fungible_resource_entity_id~1" ON non_fungible_id_definition (non_fungible_resource_entity_id, non_fungible_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_location_history_non_fungible_id_definition~" ON non_fungible_id_location_history (non_fungible_id_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_non_fungible_schema_history_resource_entity_id_from_state_v~" ON non_fungible_schema_history (resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_aggregate_history_package_entity_id_from_~" ON package_blueprint_aggregate_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_history_package_entity_id_from_state_vers~" ON package_blueprint_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_history_package_entity_id_name_version_fr~" ON package_blueprint_history (package_entity_id, name, version, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_package_code_aggregate_history_package_entity_id_from_state~" ON package_code_aggregate_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_package_code_history_package_entity_id_from_state_version" ON package_code_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE UNIQUE INDEX "IX_pending_transaction_payloads_pending_transaction_id" ON pending_transaction_payloads (pending_transaction_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_first_submitted_to_gateway_timestamp" ON pending_transactions (first_submitted_to_gateway_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_intent_hash" ON pending_transactions (intent_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE UNIQUE INDEX "IX_pending_transactions_payload_hash" ON pending_transactions (payload_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_resubmit_from_timestamp" ON pending_transactions (resubmit_from_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_resource_entity_supply_history_resource_entity_id_from_stat~" ON resource_entity_supply_history (resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE UNIQUE INDEX "IX_resource_holders_entity_id_resource_entity_id" ON resource_holders (entity_id, resource_entity_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_resource_holders_entity_id_resource_entity_id_balance" ON resource_holders (entity_id, resource_entity_id, balance); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_schema_entry_aggregate_history_entity_id_from_state_version" ON schema_entry_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_schema_entry_definition_entity_id_schema_hash" ON schema_entry_definition (entity_id, schema_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_state_history_entity_id_from_state_version" ON state_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_unverified_standard_metadata_aggregate_history_entity_id_fr~" ON unverified_standard_metadata_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_unverified_standard_metadata_entry_history_entity_id_discri~" ON unverified_standard_metadata_entry_history (entity_id, discriminator, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_epoch" ON validator_active_set_history (epoch); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_from_state_version" ON validator_active_set_history (from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_validator_public_key_history_id" ON validator_active_set_history (validator_public_key_history_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_validator_cumulative_emission_history_validator_entity_id_e~" ON validator_cumulative_emission_history (validator_entity_id, epoch_number); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_validator_public_key_history_validator_entity_id_from_state~" ON validator_public_key_history (validator_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN CREATE INDEX "IX_validator_public_key_history_validator_entity_id_key_type_k~" ON validator_public_key_history (validator_entity_id, key_type, key); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240819084018_InitialCreate') THEN INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") - VALUES ('20240816104539_InitialCreate', '8.0.2'); + VALUES ('20240819084018_InitialCreate', '8.0.2'); END IF; END $EF$; COMMIT; diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs index 41c32f112..8ee876e95 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs @@ -62,7 +62,7 @@ * permissions under this License. */ -// +// using System; using System.Collections.Generic; using System.Numerics; @@ -92,7 +92,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "account_default_deposit_rule", new[] { "accept", "reject", "allow_existing" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "account_resource_preference_rule", new[] { "allowed", "disallowed" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "authorized_depositor_badge_type", new[] { "resource", "non_fungible" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_relationship", new[] { "component_to_instantiating_package", "vault_to_resource", "royalty_vault_of_component", "validator_to_stake_vault", "validator_to_pending_xrd_withdraw_vault", "validator_to_locked_owner_stake_unit_vault", "validator_to_pending_owner_stake_unit_unlock_vault", "stake_vault_of_validator", "claim_token_of_validator", "account_locker_of_locker", "account_locker_of_account", "resource_pool_to_unit_resource", "resource_pool_to_resource", "resource_pool_to_resource_vault", "unit_vault_of_resource_pool", "resource_vault_of_resource_pool", "access_controller_to_recovery_badge", "recovery_badge_of_access_controller" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_relationship", new[] { "component_to_instantiating_package", "vault_to_resource", "royalty_vault_of_component", "validator_to_stake_vault", "validator_to_pending_xrd_withdraw_vault", "validator_to_locked_owner_stake_unit_vault", "validator_to_pending_owner_stake_unit_unlock_vault", "stake_unit_of_validator", "claim_token_of_validator", "account_locker_of_locker", "account_locker_of_account", "resource_pool_to_unit_resource", "resource_pool_to_resource", "resource_pool_to_resource_vault", "unit_resource_of_resource_pool", "resource_vault_of_resource_pool", "access_controller_to_recovery_badge", "recovery_badge_of_access_controller" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "global_consensus_manager", "global_fungible_resource", "global_non_fungible_resource", "global_generic_component", "internal_generic_component", "global_account_component", "global_package", "internal_key_value_store", "internal_fungible_vault", "internal_non_fungible_vault", "global_validator", "global_access_controller", "global_identity", "global_one_resource_pool", "global_two_resource_pool", "global_multi_resource_pool", "global_transaction_tracker", "global_account_locker" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_manifest_class", new[] { "general", "transfer", "validator_stake", "validator_unstake", "validator_claim", "account_deposit_settings_update", "pool_contribution", "pool_redemption" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_event_type", new[] { "withdrawal", "deposit" }); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/NativeResourceDetailsResolver.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/NativeResourceDetailsResolver.cs index 799d14ef1..f65123548 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/NativeResourceDetailsResolver.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/NativeResourceDetailsResolver.cs @@ -147,7 +147,7 @@ LIMIT 1 WHERE e.from_state_version <= var.state_version AND e.address = ANY(var.addresses) - AND e.correlated_entity_relationships && '{unit_vault_of_resource_pool, stake_vault_of_validator, claim_token_of_validator, recovery_badge_of_access_controller}'::entity_relationship[] + AND e.correlated_entity_relationships && '{unit_resource_of_resource_pool, stake_unit_of_validator, claim_token_of_validator, recovery_badge_of_access_controller}'::entity_relationship[] ), base_with_root AS ( SELECT @@ -158,7 +158,7 @@ base_with_root AS ( unnest(root.correlated_entity_ids) AS root_correlated_entity_id FROM base_entities base INNER JOIN entities root ON root.id = base.base_correlated_entity_id - WHERE base.base_correlated_entity_relationship = ANY('{unit_vault_of_resource_pool, stake_vault_of_validator, claim_token_of_validator, recovery_badge_of_access_controller}'::entity_relationship[]) + WHERE base.base_correlated_entity_relationship = ANY('{unit_resource_of_resource_pool, stake_unit_of_validator, claim_token_of_validator, recovery_badge_of_access_controller}'::entity_relationship[]) ) SELECT bwr.base_correlated_entity_relationship AS BaseRelationship, diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/StandardMetadataResolver.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/StandardMetadataResolver.cs index 357639373..66b228672 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/StandardMetadataResolver.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/StandardMetadataResolver.cs @@ -82,7 +82,7 @@ internal class StandardMetadataResolver { private record struct PartiallyValidatedTwoWayLink(long FromStateVersion, StandardMetadataKey Discriminator, bool IsLocked, string EntityAddress, string TargetValue, string ValidationResult); - private record struct ValidatedTwoWayLink(PartiallyValidatedTwoWayLink Link, ResolvedTwoWayLink? ResolvedTwoWayLink, string? ValidationError) + private record struct TwoWayLinkValidationResult(PartiallyValidatedTwoWayLink Link, ResolvedTwoWayLink? ResolvedTwoWayLink, string? ValidationError) { public bool IsSuccessfullyResolved([NotNullWhen(true)] out ResolvedTwoWayLink? resolved) { @@ -323,7 +323,7 @@ await Parallel.ForEachAsync(partiallyValidatedEntries, options, async (pv, inner return result.ToDictionary(e => e.Key, e => (ICollection)e.Value.ToList()); } - private async ValueTask ResolveTwoWayLink(PartiallyValidatedTwoWayLink link, bool validateOnLedgerOnly, ICollection allEntries, CancellationToken token) + private async ValueTask ResolveTwoWayLink(PartiallyValidatedTwoWayLink link, bool validateOnLedgerOnly, ICollection allEntries, CancellationToken token) { if (link.ValidationResult == StandardMetadataConstants.ValidationUnknown) { @@ -337,7 +337,7 @@ private async ValueTask ResolveTwoWayLink(PartiallyValidate return await ResolveDappClaimedWebsite(link, validateOnLedgerOnly, token); } - return new ValidatedTwoWayLink(link, null, "expected off-ledger app-check validation result, got: " + link.ValidationResult); + return new TwoWayLinkValidationResult(link, null, "expected off-ledger app-check validation result, got: " + link.ValidationResult); } if (link.Discriminator == StandardMetadataKey.DappAccountLocker) @@ -347,17 +347,17 @@ private async ValueTask ResolveTwoWayLink(PartiallyValidate return ResolveDappAccountLocker(link, allEntries); } - return new ValidatedTwoWayLink(link, null, "expected on-ledger app-check validation result, got: " + link.ValidationResult); + return new TwoWayLinkValidationResult(link, null, "expected on-ledger app-check validation result, got: " + link.ValidationResult); } if (link.ValidationResult != StandardMetadataConstants.ValidationOnLedgerSucceeded) { - return new ValidatedTwoWayLink(link, null, link.ValidationResult); + return new TwoWayLinkValidationResult(link, null, link.ValidationResult); } if (link.Discriminator == StandardMetadataKey.DappAccountType) { - return new ValidatedTwoWayLink(link, null, null); + return new TwoWayLinkValidationResult(link, null, null); } var target = (EntityAddress)link.TargetValue; @@ -370,10 +370,10 @@ private async ValueTask ResolveTwoWayLink(PartiallyValidate _ => throw CreateException(link, "unsupported entry discriminator"), }; - return new ValidatedTwoWayLink(link, resolved, null); + return new TwoWayLinkValidationResult(link, resolved, null); } - private async ValueTask ResolveDappClaimedWebsite(PartiallyValidatedTwoWayLink link, bool validateOnLedgerOnly, CancellationToken token) + private async ValueTask ResolveDappClaimedWebsite(PartiallyValidatedTwoWayLink link, bool validateOnLedgerOnly, CancellationToken token) { var claimedWebsite = link.TargetValue; @@ -407,19 +407,19 @@ private async ValueTask ResolveDappClaimedWebsite(Partially var invalidReason = await Validate(); return invalidReason == null - ? new ValidatedTwoWayLink(link, new DappClaimedWebsiteResolvedTwoWayLink(new Uri(claimedWebsite)), null) - : new ValidatedTwoWayLink(link, null, invalidReason); + ? new TwoWayLinkValidationResult(link, new DappClaimedWebsiteResolvedTwoWayLink(new Uri(claimedWebsite)), null) + : new TwoWayLinkValidationResult(link, null, invalidReason); } - private ValidatedTwoWayLink ResolveDappAccountLocker(PartiallyValidatedTwoWayLink link, ICollection allEntries) + private TwoWayLinkValidationResult ResolveDappAccountLocker(PartiallyValidatedTwoWayLink link, ICollection allEntries) { var entityAddress = (EntityAddress)link.EntityAddress; var lockerAddress = (EntityAddress)link.TargetValue; var isValid = allEntries.Any(x => x.EntityAddress == entityAddress && x.Discriminator == StandardMetadataKey.DappClaimedEntities && x.TargetValue == lockerAddress); return isValid - ? new ValidatedTwoWayLink(link, new DappAccountLockerResolvedTwoWayLink(lockerAddress), null) - : new ValidatedTwoWayLink(link, null, "claimed_entities entry with the locker address missing"); + ? new TwoWayLinkValidationResult(link, new DappAccountLockerResolvedTwoWayLink(lockerAddress), null) + : new TwoWayLinkValidationResult(link, null, "claimed_entities entry with the locker address missing"); } private Exception CreateException(PartiallyValidatedTwoWayLink entry, string details) diff --git a/tests/RadixDlt.NetworkGateway.UnitTests/Abstractions/Numerics/TokenAmountTests.cs b/tests/RadixDlt.NetworkGateway.UnitTests/Abstractions/Numerics/TokenAmountTests.cs index e41e87977..4a804d905 100644 --- a/tests/RadixDlt.NetworkGateway.UnitTests/Abstractions/Numerics/TokenAmountTests.cs +++ b/tests/RadixDlt.NetworkGateway.UnitTests/Abstractions/Numerics/TokenAmountTests.cs @@ -207,6 +207,7 @@ public void GivenNaN_SubunitsIsZero() new object[] { TokenAmount.FromStringParts(true, "1", "234"), false }, new object[] { TokenAmount.FromStringParts(false, "1", "-234"), true }, // Invalid call new object[] { TokenAmount.FromStringParts(true, "1", "-234"), true }, // Invalid call + new object[] { TokenAmount.FromDecimalString("5") / TokenAmount.Zero, true }, }; [Theory] @@ -242,4 +243,18 @@ public void Divide_ApproximateValue(string dividend, string divisor, string expe resultAsNumber.Should().BeApproximately(expectedAsNumber, 100); } + + [Theory] + [InlineData("12.5", "2", "25")] + [InlineData("2", "5", "10")] + [InlineData("2.1", "2", "4.2")] + [InlineData("50000000000", "0.123456789", "6172839450")] + public void Multiply_ExactValue(string op1, string op2, string expected) + { + var result = TokenAmount.FromDecimalString(op1) * TokenAmount.FromDecimalString(op2); + var resultAsNumber = decimal.Parse(result.ToString(), NumberFormatInfo.InvariantInfo); + var expectedAsNumber = decimal.Parse(expected, NumberFormatInfo.InvariantInfo); + + resultAsNumber.Should().Be(expectedAsNumber); + } }