diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs index a3ba53ac7..7c32ccdd1 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs @@ -651,14 +651,17 @@ private static void HookupHistory(ModelBuilder modelBuilder) .Entity() .HasIndex(e => new { e.EntityId, e.Discriminator, e.FromStateVersion }); + // Used by Data aggregator when inserting new data. modelBuilder .Entity() .HasIndex(e => new { e.EntityId, e.ResourceEntityId }) .IsUnique(); + // Used by Gateway API when querying resource holders endpoint. modelBuilder .Entity() - .HasIndex(e => new { e.ResourceEntityId, e.Balance, e.Id }); + .HasIndex(e => new { e.ResourceEntityId, e.Balance, e.EntityId }) + .IsDescending(false, true, true); modelBuilder .Entity() diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20250113104233_GenerateOrderedIndexForResourceHolders.Designer.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20250113104233_GenerateOrderedIndexForResourceHolders.Designer.cs new file mode 100644 index 000000000..28c8aedb2 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20250113104233_GenerateOrderedIndexForResourceHolders.Designer.cs @@ -0,0 +1,3118 @@ +/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands). + * + * Licensed under the Radix License, Version 1.0 (the "License"); you may not use this + * file except in compliance with the License. You may obtain a copy of the License at: + * + * radixfoundation.org/licenses/LICENSE-v1 + * + * The Licensor hereby grants permission for the Canonical version of the Work to be + * published, distributed and used under or by reference to the Licensor’s trademark + * Radix ® and use of any unregistered trade names, logos or get-up. + * + * The Licensor provides the Work (and each Contributor provides its Contributions) on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, + * including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, + * MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. + * + * Whilst the Work is capable of being deployed, used and adopted (instantiated) to create + * a distributed ledger it is your responsibility to test and validate the code, together + * with all logic and performance of that code under all foreseeable scenarios. + * + * The Licensor does not make or purport to make and hereby excludes liability for all + * and any representation, warranty or undertaking in any form whatsoever, whether express + * or implied, to any entity or person, including any representation, warranty or + * undertaking, as to the functionality security use, value or other characteristics of + * any distributed ledger nor in respect the functioning or value of any tokens which may + * be created stored or transferred using the Work. The Licensor does not warrant that the + * Work or any use of the Work complies with any law or regulation in any territory where + * it may be implemented or used or that it will be appropriate for any specific purpose. + * + * Neither the licensor nor any current or former employees, officers, directors, partners, + * trustees, representatives, agents, advisors, contractors, or volunteers of the Licensor + * shall be liable for any direct or indirect, special, incidental, consequential or other + * losses of any kind, in tort, contract or otherwise (including but not limited to loss + * of revenue, income or profits, or loss of use or data, or loss of reputation, or loss + * of any economic or other opportunity of whatsoever nature or howsoever arising), arising + * out of or in connection with (without limitation of any use, misuse, of any ledger system + * or use made or its functionality or any performance or operation of any code or protocol + * caused by bugs or programming or logic errors or otherwise); + * + * A. any offer, purchase, holding, use, sale, exchange or transmission of any + * cryptographic keys, tokens or assets created, exchanged, stored or arising from any + * interaction with the Work; + * + * B. any failure in a transmission or loss of any token or assets keys or other digital + * artefacts due to errors in transmission; + * + * C. bugs, hacks, logic errors or faults in the Work or any communication; + * + * D. system software or apparatus including but not limited to losses caused by errors + * in holding or transmitting tokens by any third-party; + * + * E. breaches or failure of security including hacker attacks, loss or disclosure of + * password, loss of private key, unauthorised use or misuse of such passwords or keys; + * + * F. any losses including loss of anticipated savings or other benefits resulting from + * use of the Work or any changes to the Work (however implemented). + * + * You are solely responsible for; testing, validating and evaluation of all operation + * logic, functionality, security and appropriateness of using the Work for any commercial + * or non-commercial purpose and for any reproduction or redistribution by You of the + * Work. You assume all risks associated with Your use of the Work and the exercise of + * permissions under this License. + */ + +// +using System; +using System.Collections.Generic; +using System.Numerics; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using RadixDlt.NetworkGateway.Abstractions.Model; +using RadixDlt.NetworkGateway.Abstractions.StandardMetadata; +using RadixDlt.NetworkGateway.PostgresIntegration; +using RadixDlt.NetworkGateway.PostgresIntegration.Models; + +#nullable disable + +namespace RadixDlt.NetworkGateway.PostgresIntegration.Migrations +{ + [DbContext(typeof(MigrationsDbContext))] + [Migration("20250113104233_GenerateOrderedIndexForResourceHolders")] + partial class GenerateOrderedIndexForResourceHolders + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + 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", "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", "entity_to_royalty_vault", "royalty_vault_of_entity", "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" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_operation_type", new[] { "resource_in_use", "account_deposited_into", "account_withdrawn_from", "account_owner_method_call", "badge_presented" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_transaction_type", new[] { "user", "round_change", "genesis_flash", "genesis_transaction", "protocol_update_flash", "protocol_update_transaction" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_type", new[] { "transaction_type", "event", "manifest_address", "affected_global_entity", "manifest_class", "event_global_emitter", "epoch_change", "resource_balance_change" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_status", new[] { "succeeded", "failed" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_type", new[] { "genesis", "user", "user_v2", "round_update", "flash" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "module_id", new[] { "main", "metadata", "royalty", "role_assignment" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "non_fungible_id_type", new[] { "string", "integer", "bytes", "ruid" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "package_vm_type", new[] { "native", "scrypto_v1" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "pending_transaction_intent_ledger_status", new[] { "unknown", "committed", "commit_pending", "permanent_rejection", "possible_to_commit", "likely_but_not_certain_rejection" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "pending_transaction_payload_ledger_status", new[] { "unknown", "committed", "commit_pending", "clashing_commit", "permanently_rejected", "transiently_accepted", "transiently_rejected" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "public_key_type", new[] { "ecdsa_secp256k1", "eddsa_ed25519" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "resource_type", new[] { "fungible", "non_fungible" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "sbor_type_kind", new[] { "well_known", "schema_local" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "standard_metadata_key", new[] { "dapp_account_type", "dapp_definition", "dapp_definitions", "dapp_claimed_websites", "dapp_claimed_entities", "dapp_account_locker" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "state_type", new[] { "json", "sbor" }); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountAuthorizedDepositorAggregateHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountEntityId") + .HasColumnType("bigint") + .HasColumnName("account_entity_id"); + + b.Property>("EntryIds") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("entry_ids"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.HasKey("Id"); + + b.HasIndex("AccountEntityId", "FromStateVersion"); + + b.ToTable("account_authorized_depositor_aggregate_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountAuthorizedDepositorEntryHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountEntityId") + .HasColumnType("bigint") + .HasColumnName("account_entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted"); + + b.Property("discriminator") + .HasColumnType("authorized_depositor_badge_type"); + + b.HasKey("Id"); + + b.HasIndex("AccountEntityId", "FromStateVersion"); + + b.ToTable("account_authorized_depositor_entry_history"); + + b.HasDiscriminator("discriminator"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountDefaultDepositRuleHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountEntityId") + .HasColumnType("bigint") + .HasColumnName("account_entity_id"); + + b.Property("DefaultDepositRule") + .HasColumnType("account_default_deposit_rule") + .HasColumnName("default_deposit_rule"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.HasKey("Id"); + + b.HasIndex("AccountEntityId", "FromStateVersion"); + + b.ToTable("account_default_deposit_rule_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountLockerEntryDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountEntityId") + .HasColumnType("bigint") + .HasColumnName("account_entity_id"); + + b.Property("AccountLockerEntityId") + .HasColumnType("bigint") + .HasColumnName("account_locker_entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("KeyValueStoreEntityId") + .HasColumnType("bigint") + .HasColumnName("key_value_store_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("AccountLockerEntityId", "AccountEntityId") + .IsUnique(); + + b.ToTable("account_locker_entry_definition"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountLockerEntryResourceVaultDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountLockerDefinitionId") + .HasColumnType("bigint") + .HasColumnName("account_locker_definition_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.Property("VaultEntityId") + .HasColumnType("bigint") + .HasColumnName("vault_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("AccountLockerDefinitionId", "FromStateVersion"); + + b.ToTable("account_locker_entry_resource_vault_definition"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountLockerEntryTouchHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountLockerDefinitionId") + .HasColumnType("bigint") + .HasColumnName("account_locker_definition_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.HasKey("Id"); + + b.HasIndex("AccountLockerDefinitionId", "FromStateVersion"); + + b.ToTable("account_locker_entry_touch_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountResourcePreferenceRuleAggregateHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountEntityId") + .HasColumnType("bigint") + .HasColumnName("account_entity_id"); + + b.Property>("EntryIds") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("entry_ids"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.HasKey("Id"); + + b.HasIndex("AccountEntityId", "FromStateVersion"); + + b.ToTable("account_resource_preference_rule_aggregate_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountResourcePreferenceRuleEntryHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountEntityId") + .HasColumnType("bigint") + .HasColumnName("account_entity_id"); + + b.Property("AccountResourcePreferenceRule") + .HasColumnType("account_resource_preference_rule") + .HasColumnName("account_resource_preference_rule"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("AccountEntityId", "ResourceEntityId", "FromStateVersion"); + + b.ToTable("account_resource_preference_rule_entry_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ComponentMethodRoyaltyAggregateHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property>("EntryIds") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("entry_ids"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.ToTable("component_method_royalty_aggregate_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ComponentMethodRoyaltyEntryHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("IsLocked") + .HasColumnType("boolean") + .HasColumnName("is_locked"); + + b.Property("MethodName") + .IsRequired() + .HasColumnType("text") + .HasColumnName("method_name"); + + b.Property("RoyaltyAmount") + .HasColumnType("jsonb") + .HasColumnName("royalty_amount"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.HasIndex("EntityId", "MethodName", "FromStateVersion"); + + b.ToTable("component_method_royalty_entry_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("text") + .HasColumnName("address"); + + b.Property>("AncestorIds") + .HasColumnType("bigint[]") + .HasColumnName("ancestor_ids"); + + b.Property>("CorrelatedEntityIds") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("correlated_entity_ids"); + + b.Property>("CorrelatedEntityRelationships") + .IsRequired() + .HasColumnType("entity_relationship[]") + .HasColumnName("correlated_entity_relationships"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("GlobalAncestorId") + .HasColumnType("bigint") + .HasColumnName("global_ancestor_id"); + + b.Property("IsGlobal") + .HasColumnType("boolean") + .HasColumnName("is_global"); + + b.Property("OwnerAncestorId") + .HasColumnType("bigint") + .HasColumnName("owner_ancestor_id"); + + b.Property("ParentAncestorId") + .HasColumnType("bigint") + .HasColumnName("parent_ancestor_id"); + + b.Property("discriminator") + .HasColumnType("entity_type"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("FromStateVersion") + .HasFilter("discriminator = 'global_validator'"); + + b.ToTable("entities"); + + b.HasDiscriminator("discriminator"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityMetadataEntryDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("Key") + .IsRequired() + .HasColumnType("text") + .HasColumnName("key"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.HasIndex("EntityId", "Key"); + + b.ToTable("entity_metadata_entry_definition"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityMetadataEntryHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityMetadataEntryDefinitionId") + .HasColumnType("bigint") + .HasColumnName("entity_metadata_entry_definition_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted"); + + b.Property("IsLocked") + .HasColumnType("boolean") + .HasColumnName("is_locked"); + + b.Property("Value") + .HasColumnType("bytea") + .HasColumnName("value"); + + b.HasKey("Id"); + + b.HasIndex("EntityMetadataEntryDefinitionId", "FromStateVersion"); + + b.ToTable("entity_metadata_entry_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityMetadataTotalsHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("TotalEntriesExcludingDeleted") + .HasColumnType("bigint") + .HasColumnName("total_entries_excluding_deleted"); + + b.Property("TotalEntriesIncludingDeleted") + .HasColumnType("bigint") + .HasColumnName("total_entries_including_deleted"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.ToTable("entity_metadata_totals_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityResourceBalanceHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Balance") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("balance"); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "ResourceEntityId", "FromStateVersion"); + + b.ToTable("entity_resource_balance_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityResourceEntryDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.Property("ResourceType") + .HasColumnType("resource_type") + .HasColumnName("resource_type"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.HasIndex(new[] { "EntityId", "FromStateVersion" }, "IX_entity_resource_entry_definition_fungibles") + .HasFilter("resource_type = 'fungible'"); + + b.HasIndex(new[] { "EntityId", "FromStateVersion" }, "IX_entity_resource_entry_definition_non_fungibles") + .HasFilter("resource_type = 'non_fungible'"); + + b.ToTable("entity_resource_entry_definition"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityResourceTotalsHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("TotalCount") + .HasColumnType("bigint") + .HasColumnName("total_count"); + + b.Property("TotalFungibleCount") + .HasColumnType("bigint") + .HasColumnName("total_fungible_count"); + + b.Property("TotalNonFungibleCount") + .HasColumnType("bigint") + .HasColumnName("total_non_fungible_count"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.ToTable("entity_resource_totals_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityResourceVaultEntryDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.Property("VaultEntityId") + .HasColumnType("bigint") + .HasColumnName("vault_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "ResourceEntityId", "FromStateVersion"); + + b.ToTable("entity_resource_vault_entry_definition"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityResourceVaultTotalsHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.Property("TotalCount") + .HasColumnType("bigint") + .HasColumnName("total_count"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "ResourceEntityId", "FromStateVersion"); + + b.ToTable("entity_resource_vault_totals_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityRoleAssignmentsAggregateHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property>("EntryIds") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("entry_ids"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("OwnerRoleId") + .HasColumnType("bigint") + .HasColumnName("owner_role_id"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.ToTable("entity_role_assignments_aggregate_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityRoleAssignmentsEntryHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted"); + + b.Property("KeyModule") + .HasColumnType("module_id") + .HasColumnName("key_module"); + + b.Property("KeyRole") + .IsRequired() + .HasColumnType("text") + .HasColumnName("key_role"); + + b.Property("RoleAssignments") + .HasColumnType("jsonb") + .HasColumnName("role_assignments"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "KeyRole", "KeyModule", "FromStateVersion"); + + b.ToTable("entity_role_assignments_entry_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityRoleAssignmentsOwnerRoleHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("RoleAssignments") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("role_assignments"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.ToTable("entity_role_assignments_owner_role_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.KeyValueStoreEntryDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("Key") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("key"); + + b.Property("KeyValueStoreEntityId") + .HasColumnType("bigint") + .HasColumnName("key_value_store_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("KeyValueStoreEntityId", "FromStateVersion"); + + b.HasIndex("KeyValueStoreEntityId", "Key") + .HasDatabaseName("IX_key_value_store_entry_definition_key_value_store_entity_id~1"); + + b.ToTable("key_value_store_entry_definition"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.KeyValueStoreEntryHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted"); + + b.Property("IsLocked") + .HasColumnType("boolean") + .HasColumnName("is_locked"); + + b.Property("KeyValueStoreEntryDefinitionId") + .HasColumnType("bigint") + .HasColumnName("key_value_store_entry_definition_id"); + + b.Property("Value") + .HasColumnType("bytea") + .HasColumnName("value"); + + b.HasKey("Id"); + + b.HasIndex("KeyValueStoreEntryDefinitionId", "FromStateVersion"); + + b.ToTable("key_value_store_entry_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.KeyValueStoreSchemaHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("KeySborTypeKind") + .HasColumnType("sbor_type_kind") + .HasColumnName("key_sbor_type_kind"); + + b.Property("KeySchemaDefiningEntityId") + .HasColumnType("bigint") + .HasColumnName("key_schema_defining_entity_id"); + + b.Property("KeySchemaHash") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("key_schema_hash"); + + b.Property("KeyTypeIndex") + .HasColumnType("bigint") + .HasColumnName("key_type_index"); + + b.Property("KeyValueStoreEntityId") + .HasColumnType("bigint") + .HasColumnName("key_value_store_entity_id"); + + b.Property("ValueSborTypeKind") + .HasColumnType("sbor_type_kind") + .HasColumnName("value_sbor_type_kind"); + + b.Property("ValueSchemaDefiningEntityId") + .HasColumnType("bigint") + .HasColumnName("value_schema_defining_entity_id"); + + b.Property("ValueSchemaHash") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("value_schema_hash"); + + b.Property("ValueTypeIndex") + .HasColumnType("bigint") + .HasColumnName("value_type_index"); + + b.HasKey("Id"); + + b.HasIndex("KeyValueStoreEntityId", "FromStateVersion"); + + b.ToTable("key_value_store_schema_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.KeyValueStoreTotalsHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("TotalEntriesExcludingDeleted") + .HasColumnType("bigint") + .HasColumnName("total_entries_excluding_deleted"); + + b.Property("TotalEntriesIncludingDeleted") + .HasColumnType("bigint") + .HasColumnName("total_entries_including_deleted"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.ToTable("key_value_store_totals_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerFinalizedSubintent", b => + { + b.Property("SubintentHash") + .HasMaxLength(90) + .HasColumnType("character varying(90)") + .HasColumnName("subintent_hash"); + + b.Property("FinalizedAtStateVersion") + .HasColumnType("bigint") + .HasColumnName("finalized_at_state_version"); + + b.Property("FinalizedAtTransactionIntentHash") + .IsRequired() + .HasMaxLength(90) + .HasColumnType("character varying(90)") + .HasColumnName("finalized_at_transaction_intent_hash"); + + b.HasKey("SubintentHash"); + + b.ToTable("ledger_finalized_subintents"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransaction", b => + { + b.Property("StateVersion") + .HasColumnType("bigint") + .HasColumnName("state_version"); + + b.Property("AffectedGlobalEntities") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("affected_global_entities"); + + b.Property("BalanceChanges") + .HasColumnType("jsonb") + .HasColumnName("balance_changes"); + + b.Property("CreatedTimestamp") + .HasColumnType("timestamp with time zone") + .HasColumnName("created_timestamp"); + + b.Property("Epoch") + .HasColumnType("bigint") + .HasColumnName("epoch"); + + b.Property("FeePaid") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("fee_paid"); + + b.Property("IndexInEpoch") + .HasColumnType("bigint") + .HasColumnName("index_in_epoch"); + + b.Property("IndexInRound") + .HasColumnType("bigint") + .HasColumnName("index_in_round"); + + b.Property("NormalizedRoundTimestamp") + .HasColumnType("timestamp with time zone") + .HasColumnName("normalized_round_timestamp"); + + b.Property("ReceiptCostingParameters") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("receipt_costing_parameters"); + + b.Property("ReceiptErrorMessage") + .HasColumnType("text") + .HasColumnName("receipt_error_message"); + + b.Property("ReceiptFeeDestination") + .HasColumnType("jsonb") + .HasColumnName("receipt_fee_destination"); + + b.Property("ReceiptFeeSource") + .HasColumnType("jsonb") + .HasColumnName("receipt_fee_source"); + + b.Property("ReceiptFeeSummary") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("receipt_fee_summary"); + + b.Property("ReceiptNextEpoch") + .HasColumnType("jsonb") + .HasColumnName("receipt_next_epoch"); + + b.Property("ReceiptOutput") + .HasColumnType("jsonb") + .HasColumnName("receipt_output"); + + b.Property("ReceiptStateUpdates") + .HasColumnType("jsonb") + .HasColumnName("receipt_state_updates"); + + b.Property("ReceiptStatus") + .HasColumnType("ledger_transaction_status") + .HasColumnName("receipt_status"); + + b.Property("ReceiptTreeHash") + .IsRequired() + .HasColumnType("text") + .HasColumnName("receipt_tree_hash"); + + b.Property("RoundInEpoch") + .HasColumnType("bigint") + .HasColumnName("round_in_epoch"); + + b.Property("RoundTimestamp") + .HasColumnType("timestamp with time zone") + .HasColumnName("round_timestamp"); + + b.Property("StateTreeHash") + .IsRequired() + .HasColumnType("text") + .HasColumnName("state_tree_hash"); + + b.Property("TipPaid") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("tip_paid"); + + b.Property("TransactionTreeHash") + .IsRequired() + .HasColumnType("text") + .HasColumnName("transaction_tree_hash"); + + b.Property("discriminator") + .HasColumnType("ledger_transaction_type"); + + b.HasKey("StateVersion"); + + b.HasIndex("RoundTimestamp"); + + b.HasIndex("Epoch", "RoundInEpoch") + .IsUnique() + .HasFilter("index_in_round = 0"); + + b.HasIndex("ReceiptStatus", "StateVersion"); + + b.ToTable("ledger_transactions"); + + b.HasDiscriminator("discriminator"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionEvents", b => + { + b.Property("StateVersion") + .HasColumnType("bigint") + .HasColumnName("state_version"); + + b.Property("ReceiptEventEmitters") + .IsRequired() + .HasColumnType("jsonb[]") + .HasColumnName("receipt_event_emitters"); + + b.Property("ReceiptEventNames") + .IsRequired() + .HasColumnType("text[]") + .HasColumnName("receipt_event_names"); + + b.Property("ReceiptEventSborTypeKinds") + .IsRequired() + .HasColumnType("sbor_type_kind[]") + .HasColumnName("receipt_event_sbor_type_kinds"); + + b.Property("ReceiptEventSbors") + .IsRequired() + .HasColumnType("bytea[]") + .HasColumnName("receipt_event_sbors"); + + b.Property("ReceiptEventSchemaEntityIds") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("receipt_event_schema_entity_ids"); + + b.Property("ReceiptEventSchemaHashes") + .IsRequired() + .HasColumnType("bytea[]") + .HasColumnName("receipt_event_schema_hashes"); + + b.Property("ReceiptEventTypeIndexes") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("receipt_event_type_indexes"); + + b.HasKey("StateVersion"); + + b.ToTable("ledger_transaction_events"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("StateVersion") + .HasColumnType("bigint") + .HasColumnName("state_version"); + + b.Property("discriminator") + .HasColumnType("ledger_transaction_marker_type"); + + b.HasKey("Id"); + + b.HasIndex("StateVersion"); + + b.ToTable("ledger_transaction_markers"); + + b.HasDiscriminator("discriminator"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionSubintentData", b => + { + b.Property("StateVersion") + .HasColumnType("bigint") + .HasColumnName("state_version"); + + b.Property>("ChildSubintentHashes") + .IsRequired() + .HasColumnType("text[]") + .HasColumnName("child_subintent_hashes"); + + b.Property("SubintentData") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("subintent_data"); + + b.HasKey("StateVersion"); + + b.ToTable("ledger_transaction_subintent_data"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleIdDataHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Data") + .HasColumnType("bytea") + .HasColumnName("data"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted"); + + b.Property("IsLocked") + .HasColumnType("boolean") + .HasColumnName("is_locked"); + + b.Property("NonFungibleIdDefinitionId") + .HasColumnType("bigint") + .HasColumnName("non_fungible_id_definition_id"); + + b.HasKey("Id"); + + b.HasIndex("NonFungibleIdDefinitionId", "FromStateVersion"); + + b.ToTable("non_fungible_id_data_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleIdDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("NonFungibleId") + .IsRequired() + .HasColumnType("text") + .HasColumnName("non_fungible_id"); + + b.Property("NonFungibleResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("non_fungible_resource_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("NonFungibleResourceEntityId", "FromStateVersion"); + + b.HasIndex("NonFungibleResourceEntityId", "NonFungibleId", "FromStateVersion") + .IsUnique() + .HasDatabaseName("IX_non_fungible_id_definition_non_fungible_resource_entity_id~1"); + + b.ToTable("non_fungible_id_definition"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleIdLocationHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("NonFungibleIdDefinitionId") + .HasColumnType("bigint") + .HasColumnName("non_fungible_id_definition_id"); + + b.Property("VaultEntityId") + .HasColumnType("bigint") + .HasColumnName("vault_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("NonFungibleIdDefinitionId", "FromStateVersion"); + + b.ToTable("non_fungible_id_location_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleSchemaHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.Property("SborTypeKind") + .HasColumnType("sbor_type_kind") + .HasColumnName("sbor_type_kind"); + + b.Property("SchemaDefiningEntityId") + .HasColumnType("bigint") + .HasColumnName("schema_defining_entity_id"); + + b.Property("SchemaHash") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("schema_hash"); + + b.Property("TypeIndex") + .HasColumnType("bigint") + .HasColumnName("type_index"); + + b.HasKey("Id"); + + b.HasIndex("ResourceEntityId", "FromStateVersion"); + + b.ToTable("non_fungible_schema_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleVaultEntryDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("NonFungibleIdDefinitionId") + .HasColumnType("bigint") + .HasColumnName("non_fungible_id_definition_id"); + + b.Property("VaultEntityId") + .HasColumnType("bigint") + .HasColumnName("vault_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("VaultEntityId", "FromStateVersion"); + + b.ToTable("non_fungible_vault_entry_definition"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleVaultEntryHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted"); + + b.Property("NonFungibleVaultEntryDefinitionId") + .HasColumnType("bigint") + .HasColumnName("non_fungible_vault_entry_definition_id"); + + b.HasKey("Id"); + + b.HasIndex("NonFungibleVaultEntryDefinitionId", "FromStateVersion"); + + b.ToTable("non_fungible_vault_entry_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PackageBlueprintAggregateHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property>("PackageBlueprintIds") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("package_blueprint_ids"); + + b.Property("PackageEntityId") + .HasColumnType("bigint") + .HasColumnName("package_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("PackageEntityId", "FromStateVersion"); + + b.ToTable("package_blueprint_aggregate_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PackageBlueprintHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AuthTemplate") + .HasColumnType("jsonb") + .HasColumnName("auth_template"); + + b.Property("AuthTemplateIsLocked") + .HasColumnType("boolean") + .HasColumnName("auth_template_is_locked"); + + b.Property("Definition") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("definition"); + + b.Property>("DependantEntityIds") + .HasColumnType("bigint[]") + .HasColumnName("dependant_entity_ids"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("PackageEntityId") + .HasColumnType("bigint") + .HasColumnName("package_entity_id"); + + b.Property("RoyaltyConfig") + .HasColumnType("jsonb") + .HasColumnName("royalty_config"); + + b.Property("RoyaltyConfigIsLocked") + .HasColumnType("boolean") + .HasColumnName("royalty_config_is_locked"); + + b.Property("Version") + .IsRequired() + .HasColumnType("text") + .HasColumnName("version"); + + b.HasKey("Id"); + + b.HasIndex("PackageEntityId", "FromStateVersion"); + + b.HasIndex("PackageEntityId", "Name", "Version", "FromStateVersion"); + + b.ToTable("package_blueprint_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PackageCodeAggregateHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property>("PackageCodeIds") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("package_code_ids"); + + b.Property("PackageEntityId") + .HasColumnType("bigint") + .HasColumnName("package_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("PackageEntityId", "FromStateVersion"); + + b.ToTable("package_code_aggregate_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PackageCodeHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("code"); + + b.Property("CodeHash") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("code_hash"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted"); + + b.Property("PackageEntityId") + .HasColumnType("bigint") + .HasColumnName("package_entity_id"); + + b.Property("VmType") + .HasColumnType("package_vm_type") + .HasColumnName("vm_type"); + + b.HasKey("Id"); + + b.HasIndex("PackageEntityId", "FromStateVersion"); + + b.ToTable("package_code_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PendingTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EndEpochExclusive") + .HasColumnType("bigint") + .HasColumnName("end_epoch_exclusive"); + + b.Property("IntentHash") + .IsRequired() + .HasColumnType("text") + .HasColumnName("intent_hash"); + + b.Property("PayloadHash") + .IsRequired() + .HasColumnType("text") + .HasColumnName("payload_hash"); + + b.Property("PayloadId") + .HasColumnType("bigint") + .HasColumnName("payload_id"); + + b.Property("VersionControl") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("xid") + .HasColumnName("xmin"); + + b.HasKey("Id"); + + b.HasIndex("IntentHash"); + + b.HasIndex("PayloadHash") + .IsUnique(); + + b.ToTable("pending_transactions"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PendingTransactionPayload", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("NotarizedTransactionBlob") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("notarized_transaction_blob"); + + b.Property("PendingTransactionId") + .HasColumnType("bigint") + .HasColumnName("pending_transaction_id"); + + b.HasKey("Id"); + + b.HasIndex("PendingTransactionId") + .IsUnique(); + + b.ToTable("pending_transaction_payloads"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceEntitySupplyHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.Property("TotalBurned") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("total_burned"); + + b.Property("TotalMinted") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("total_minted"); + + b.Property("TotalSupply") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("total_supply"); + + b.HasKey("Id"); + + b.HasIndex("ResourceEntityId", "FromStateVersion"); + + b.ToTable("resource_entity_supply_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceHolder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Balance") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("balance"); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("LastUpdatedAtStateVersion") + .HasColumnType("bigint") + .HasColumnName("last_updated_at_state_version"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "ResourceEntityId") + .IsUnique(); + + b.HasIndex("ResourceEntityId", "Balance", "EntityId") + .IsDescending(false, true, true); + + b.ToTable("resource_holders"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.SchemaEntryAggregateHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property>("EntryIds") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("entry_ids"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.ToTable("schema_entry_aggregate_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.SchemaEntryDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("Schema") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("schema"); + + b.Property("SchemaHash") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("schema_hash"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "SchemaHash"); + + b.ToTable("schema_entry_definition"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.StateHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("discriminator") + .HasColumnType("state_type"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.ToTable("state_history"); + + b.HasDiscriminator("discriminator"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.UnverifiedStandardMetadataAggregateHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property>("EntryIds") + .IsRequired() + .HasColumnType("bigint[]") + .HasColumnName("entry_ids"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "FromStateVersion"); + + b.ToTable("unverified_standard_metadata_aggregate_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.UnverifiedStandardMetadataEntryHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Discriminator") + .HasColumnType("standard_metadata_key") + .HasColumnName("discriminator"); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("IsDeleted") + .HasColumnType("boolean") + .HasColumnName("is_deleted"); + + b.Property("IsLocked") + .HasColumnType("boolean") + .HasColumnName("is_locked"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "Discriminator", "FromStateVersion"); + + b.ToTable("unverified_standard_metadata_entry_history"); + + b.HasDiscriminator("Discriminator"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ValidatorActiveSetHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("bigint") + .HasColumnName("epoch"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("Stake") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("stake"); + + b.Property("ValidatorPublicKeyHistoryId") + .HasColumnType("bigint") + .HasColumnName("validator_public_key_history_id"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("FromStateVersion"); + + b.HasIndex("ValidatorPublicKeyHistoryId"); + + b.ToTable("validator_active_set_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ValidatorCumulativeEmissionHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EpochNumber") + .HasColumnType("bigint") + .HasColumnName("epoch_number"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("ParticipationInActiveSet") + .HasColumnType("bigint") + .HasColumnName("participation_in_active_set"); + + b.Property("ProposalsMade") + .HasColumnType("bigint") + .HasColumnName("proposals_made"); + + b.Property("ProposalsMissed") + .HasColumnType("bigint") + .HasColumnName("proposals_missed"); + + b.Property("ValidatorEntityId") + .HasColumnType("bigint") + .HasColumnName("validator_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("ValidatorEntityId", "EpochNumber"); + + b.HasIndex("ValidatorEntityId", "FromStateVersion"); + + b.ToTable("validator_cumulative_emission_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ValidatorPublicKeyHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("Key") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("key"); + + b.Property("KeyType") + .HasColumnType("public_key_type") + .HasColumnName("key_type"); + + b.Property("ValidatorEntityId") + .HasColumnType("bigint") + .HasColumnName("validator_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("ValidatorEntityId", "FromStateVersion"); + + b.HasIndex("ValidatorEntityId", "KeyType", "Key"); + + b.ToTable("validator_public_key_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.VaultBalanceHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Balance") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("balance"); + + b.Property("FromStateVersion") + .HasColumnType("bigint") + .HasColumnName("from_state_version"); + + b.Property("VaultEntityId") + .HasColumnType("bigint") + .HasColumnName("vault_entity_id"); + + b.HasKey("Id"); + + b.HasIndex("VaultEntityId", "FromStateVersion"); + + b.ToTable("vault_balance_history"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountAuthorizedNonFungibleBadgeDepositorEntryHistory", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountAuthorizedDepositorEntryHistory"); + + b.Property("NonFungibleId") + .IsRequired() + .HasColumnType("text") + .HasColumnName("non_fungible_id"); + + b.Property("ResourceEntityId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.HasIndex("AccountEntityId", "ResourceEntityId", "NonFungibleId", "FromStateVersion") + .HasDatabaseName("IX_account_authorized_depositor_entry_history_account_entity_~1") + .HasFilter("discriminator = 'non_fungible'"); + + b.ToTable("account_authorized_depositor_entry_history"); + + b.HasDiscriminator().HasValue(AuthorizedDepositorBadgeType.NonFungible); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountAuthorizedResourceBadgeDepositorEntryHistory", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountAuthorizedDepositorEntryHistory"); + + b.Property("ResourceEntityId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.HasIndex("AccountEntityId", "ResourceEntityId", "FromStateVersion") + .HasDatabaseName("IX_account_authorized_depositor_entry_history_account_entity_~2") + .HasFilter("discriminator = 'resource'"); + + b.ToTable("account_authorized_depositor_entry_history"); + + b.HasDiscriminator().HasValue(AuthorizedDepositorBadgeType.Resource); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalAccessControllerEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalAccessController); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalAccountEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalAccountComponent); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalAccountLockerEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalAccountLocker); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalConsensusManager", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalConsensusManager); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalFungibleResourceEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.Property("Divisibility") + .HasColumnType("integer") + .HasColumnName("divisibility"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalFungibleResource); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalGenericComponentEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalGenericComponent); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalIdentityEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalIdentity); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalMultiResourcePoolEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalMultiResourcePool); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalNonFungibleResourceEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.Property>("NonFungibleDataMutableFields") + .IsRequired() + .HasColumnType("text[]") + .HasColumnName("non_fungible_data_mutable_fields"); + + b.Property("NonFungibleIdType") + .HasColumnType("non_fungible_id_type") + .HasColumnName("non_fungible_id_type"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalNonFungibleResource); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalOneResourcePoolEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalOneResourcePool); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalPackageEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalPackage); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalTransactionTrackerEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalTransactionTracker); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalTwoResourcePoolEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalTwoResourcePool); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalValidatorEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.GlobalValidator); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.InternalFungibleVaultEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.InternalFungibleVault); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.InternalGenericComponentEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.InternalGenericComponent); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.InternalKeyValueStoreEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.InternalKeyValueStore); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.InternalNonFungibleVaultEntity", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); + + b.Property>("AssignedModuleIds") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("module_id[]") + .HasColumnName("assigned_module_ids"); + + b.Property("BlueprintName") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_name"); + + b.Property("BlueprintVersion") + .IsRequired() + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text") + .HasColumnName("blueprint_version"); + + b.ToTable("entities"); + + b.HasDiscriminator().HasValue(EntityType.InternalNonFungibleVault); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.BaseUserLedgerTransaction", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransaction"); + + b.Property("IntentHash") + .IsRequired() + .HasColumnType("text") + .HasColumnName("intent_hash"); + + b.Property("ManifestClasses") + .IsRequired() + .HasColumnType("ledger_transaction_manifest_class[]") + .HasColumnName("manifest_classes"); + + b.Property("ManifestInstructions") + .IsRequired() + .HasColumnType("text") + .HasColumnName("manifest_instructions"); + + b.Property("Message") + .HasColumnType("jsonb") + .HasColumnName("message"); + + b.Property("PayloadHash") + .IsRequired() + .HasColumnType("text") + .HasColumnName("payload_hash"); + + b.Property("RawPayload") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("raw_payload"); + + b.Property("SignedIntentHash") + .IsRequired() + .HasColumnType("text") + .HasColumnName("signed_intent_hash"); + + b.HasIndex("IntentHash") + .HasFilter("intent_hash IS NOT NULL"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("IntentHash"), "hash"); + + b.ToTable("ledger_transactions"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.FlashLedgerTransaction", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransaction"); + + b.ToTable("ledger_transactions"); + + b.HasDiscriminator().HasValue(LedgerTransactionType.Flash); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GenesisLedgerTransaction", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransaction"); + + b.ToTable("ledger_transactions"); + + b.HasDiscriminator().HasValue(LedgerTransactionType.Genesis); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.RoundUpdateLedgerTransaction", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransaction"); + + b.ToTable("ledger_transactions"); + + b.HasDiscriminator().HasValue(LedgerTransactionType.RoundUpdate); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AffectedGlobalEntityTransactionMarker", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); + + b.Property("EntityId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.HasIndex("EntityId", "StateVersion") + .HasDatabaseName("IX_ledger_transaction_markers_entity_id_state_version1") + .HasFilter("discriminator = 'affected_global_entity'"); + + b.ToTable("ledger_transaction_markers"); + + b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.AffectedGlobalEntity); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EpochChangeLedgerTransactionMarker", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); + + b.Property("EpochChange") + .HasColumnType("boolean") + .HasColumnName("epoch_change"); + + b.HasIndex("EpochChange", "StateVersion") + .HasFilter("discriminator = 'epoch_change'"); + + b.ToTable("ledger_transaction_markers"); + + b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.EpochChange); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EventGlobalEmitterTransactionMarker", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); + + b.Property("EntityId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.HasIndex("EntityId", "StateVersion") + .HasFilter("discriminator = 'event_global_emitter'"); + + b.ToTable("ledger_transaction_markers"); + + b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.EventGlobalEmitter); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EventLedgerTransactionMarker", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); + + b.Property("EntityId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("EventType") + .HasColumnType("ledger_transaction_marker_event_type") + .HasColumnName("event_type"); + + b.Property("Quantity") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("quantity"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.HasIndex("EventType", "EntityId", "StateVersion") + .HasFilter("discriminator = 'event'"); + + b.ToTable("ledger_transaction_markers"); + + b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.Event); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ManifestAddressLedgerTransactionMarker", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); + + b.Property("EntityId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("OperationType") + .HasColumnType("ledger_transaction_marker_operation_type") + .HasColumnName("operation_type"); + + b.HasIndex("OperationType", "EntityId", "StateVersion") + .HasFilter("discriminator = 'manifest_address'"); + + b.ToTable("ledger_transaction_markers"); + + b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.ManifestAddress); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ManifestClassMarker", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); + + b.Property("IsMostSpecific") + .HasColumnType("boolean") + .HasColumnName("is_most_specific"); + + b.Property("ManifestClass") + .HasColumnType("ledger_transaction_manifest_class") + .HasColumnName("manifest_class"); + + b.HasIndex(new[] { "ManifestClass", "StateVersion" }, "IX_ledger_transaction_markers_manifest_class") + .HasFilter("discriminator = 'manifest_class'"); + + b.HasIndex(new[] { "ManifestClass", "StateVersion" }, "IX_ledger_transaction_markers_manifest_class_is_most_specific") + .HasFilter("discriminator = 'manifest_class' and is_most_specific = true"); + + b.ToTable("ledger_transaction_markers"); + + b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.ManifestClass); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceBalanceChangeTransactionMarker", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); + + b.Property("EntityId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.HasIndex("EntityId", "StateVersion") + .HasDatabaseName("IX_ledger_transaction_markers_resource_balance_change") + .HasFilter("discriminator = 'resource_balance_change'"); + + b.ToTable("ledger_transaction_markers"); + + b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.ResourceBalanceChange); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.TransactionTypeLedgerTransactionMarker", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); + + b.Property("TransactionType") + .HasColumnType("ledger_transaction_marker_transaction_type") + .HasColumnName("transaction_type"); + + b.HasIndex("TransactionType", "StateVersion") + .HasFilter("discriminator = 'transaction_type'"); + + b.ToTable("ledger_transaction_markers"); + + b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.TransactionType); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.JsonStateHistory", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.StateHistory"); + + b.Property("JsonState") + .IsRequired() + .HasColumnType("jsonb") + .HasColumnName("json_state"); + + b.ToTable("state_history"); + + b.HasDiscriminator().HasValue(StateType.Json); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.SborStateHistory", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.StateHistory"); + + b.Property("SborState") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("sbor_state"); + + b.Property("SborTypeKind") + .HasColumnType("sbor_type_kind") + .HasColumnName("sbor_type_kind"); + + b.Property("SchemaDefiningEntityId") + .HasColumnType("bigint") + .HasColumnName("schema_defining_entity_id"); + + b.Property("SchemaHash") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("schema_hash"); + + b.Property("TypeIndex") + .HasColumnType("bigint") + .HasColumnName("type_index"); + + b.ToTable("state_history"); + + b.HasDiscriminator().HasValue(StateType.Sbor); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.DappAccountLockerUnverifiedStandardMetadataEntryHistory", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.UnverifiedStandardMetadataEntryHistory"); + + b.Property("EntityIds") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("bigint[]") + .HasColumnName("entity_ids"); + + b.ToTable("unverified_standard_metadata_entry_history"); + + b.HasDiscriminator().HasValue(StandardMetadataKey.DappAccountLocker); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.DappAccountTypeUnverifiedStandardMetadataEntryHistory", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.UnverifiedStandardMetadataEntryHistory"); + + b.Property("Values") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text[]") + .HasColumnName("values"); + + b.ToTable("unverified_standard_metadata_entry_history"); + + b.HasDiscriminator().HasValue(StandardMetadataKey.DappAccountType); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.DappClaimedEntitiesUnverifiedStandardMetadataEntryHistory", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.UnverifiedStandardMetadataEntryHistory"); + + b.Property("EntityIds") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("bigint[]") + .HasColumnName("entity_ids"); + + b.ToTable("unverified_standard_metadata_entry_history"); + + b.HasDiscriminator().HasValue(StandardMetadataKey.DappClaimedEntities); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.DappClaimedWebsitesUnverifiedStandardMetadataEntryHistory", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.UnverifiedStandardMetadataEntryHistory"); + + b.Property("Values") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("text[]") + .HasColumnName("values"); + + b.ToTable("unverified_standard_metadata_entry_history"); + + b.HasDiscriminator().HasValue(StandardMetadataKey.DappClaimedWebsites); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.DappDefinitionUnverifiedStandardMetadataEntryHistory", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.UnverifiedStandardMetadataEntryHistory"); + + b.Property("EntityIds") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("bigint[]") + .HasColumnName("entity_ids"); + + b.ToTable("unverified_standard_metadata_entry_history"); + + b.HasDiscriminator().HasValue(StandardMetadataKey.DappDefinition); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.DappDefinitionsUnverifiedStandardMetadataEntryHistory", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.UnverifiedStandardMetadataEntryHistory"); + + b.Property("EntityIds") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("bigint[]") + .HasColumnName("entity_ids"); + + b.ToTable("unverified_standard_metadata_entry_history"); + + b.HasDiscriminator().HasValue(StandardMetadataKey.DappDefinitions); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.UserLedgerTransactionV1", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.BaseUserLedgerTransaction"); + + b.ToTable("ledger_transactions"); + + b.HasDiscriminator().HasValue(LedgerTransactionType.User); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.UserLedgerTransactionV2", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.BaseUserLedgerTransaction"); + + b.ToTable("ledger_transactions"); + + b.HasDiscriminator().HasValue(LedgerTransactionType.UserV2); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PendingTransaction", b => + { + b.OwnsOne("RadixDlt.NetworkGateway.PostgresIntegration.Models.PendingTransactionGatewayHandling", "GatewayHandling", b1 => + { + b1.Property("PendingTransactionId") + .HasColumnType("bigint"); + + b1.Property("AttemptedSubmissionToNodesCount") + .HasColumnType("integer") + .HasColumnName("node_submission_count"); + + b1.Property("FirstSubmittedToGatewayTimestamp") + .HasColumnType("timestamp with time zone") + .HasColumnName("first_submitted_to_gateway_timestamp"); + + b1.Property("HandlingStatusReason") + .HasColumnType("text") + .HasColumnName("handling_status_reason"); + + b1.Property("ResubmitFromTimestamp") + .HasColumnType("timestamp with time zone") + .HasColumnName("resubmit_from_timestamp"); + + b1.HasKey("PendingTransactionId"); + + b1.HasIndex("FirstSubmittedToGatewayTimestamp"); + + b1.HasIndex("ResubmitFromTimestamp"); + + b1.ToTable("pending_transactions"); + + b1.WithOwner() + .HasForeignKey("PendingTransactionId"); + }); + + b.OwnsOne("RadixDlt.NetworkGateway.PostgresIntegration.Models.PendingTransactionLedgerDetails", "LedgerDetails", b1 => + { + b1.Property("PendingTransactionId") + .HasColumnType("bigint"); + + b1.Property("CommitTimestamp") + .HasColumnType("timestamp with time zone") + .HasColumnName("commit_timestamp"); + + b1.Property("InitialRejectionReason") + .HasColumnType("text") + .HasColumnName("initial_rejection_reason"); + + b1.Property("IntentLedgerStatus") + .HasColumnType("pending_transaction_intent_ledger_status") + .HasColumnName("intent_status"); + + b1.Property("LatestRejectionReason") + .HasColumnType("text") + .HasColumnName("latest_rejection_reason"); + + b1.Property("LatestRejectionTimestamp") + .HasColumnType("timestamp with time zone") + .HasColumnName("latest_rejection_timestamp"); + + b1.Property("PayloadLedgerStatus") + .HasColumnType("pending_transaction_payload_ledger_status") + .HasColumnName("payload_status"); + + b1.HasKey("PendingTransactionId"); + + b1.ToTable("pending_transactions"); + + b1.WithOwner() + .HasForeignKey("PendingTransactionId"); + }); + + b.OwnsOne("RadixDlt.NetworkGateway.PostgresIntegration.Models.PendingTransactionNetworkDetails", "NetworkDetails", b1 => + { + b1.Property("PendingTransactionId") + .HasColumnType("bigint"); + + b1.Property("LastSubmitErrorTitle") + .HasColumnType("text") + .HasColumnName("last_submit_error"); + + b1.Property("LatestNodeSubmissionTimestamp") + .HasColumnType("timestamp with time zone") + .HasColumnName("latest_node_submission_timestamp"); + + b1.Property("LatestNodeSubmissionWasAccepted") + .HasColumnType("boolean") + .HasColumnName("latest_node_submission_was_accepted"); + + b1.Property("LatestSubmittedToNodeName") + .HasColumnType("text") + .HasColumnName("latest_submitted_to_node_name"); + + b1.HasKey("PendingTransactionId"); + + b1.ToTable("pending_transactions"); + + b1.WithOwner() + .HasForeignKey("PendingTransactionId"); + }); + + b.Navigation("GatewayHandling") + .IsRequired(); + + b.Navigation("LedgerDetails") + .IsRequired(); + + b.Navigation("NetworkDetails") + .IsRequired(); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PendingTransactionPayload", b => + { + b.HasOne("RadixDlt.NetworkGateway.PostgresIntegration.Models.PendingTransaction", "PendingTransaction") + .WithOne("Payload") + .HasForeignKey("RadixDlt.NetworkGateway.PostgresIntegration.Models.PendingTransactionPayload", "PendingTransactionId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("PendingTransaction"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ValidatorActiveSetHistory", b => + { + b.HasOne("RadixDlt.NetworkGateway.PostgresIntegration.Models.ValidatorPublicKeyHistory", "PublicKey") + .WithMany() + .HasForeignKey("ValidatorPublicKeyHistoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("PublicKey"); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PendingTransaction", b => + { + b.Navigation("Payload"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20250113104233_GenerateOrderedIndexForResourceHolders.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20250113104233_GenerateOrderedIndexForResourceHolders.cs new file mode 100644 index 000000000..fb2c76d39 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20250113104233_GenerateOrderedIndexForResourceHolders.cs @@ -0,0 +1,101 @@ +/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands). + * + * Licensed under the Radix License, Version 1.0 (the "License"); you may not use this + * file except in compliance with the License. You may obtain a copy of the License at: + * + * radixfoundation.org/licenses/LICENSE-v1 + * + * The Licensor hereby grants permission for the Canonical version of the Work to be + * published, distributed and used under or by reference to the Licensor’s trademark + * Radix ® and use of any unregistered trade names, logos or get-up. + * + * The Licensor provides the Work (and each Contributor provides its Contributions) on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, + * including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, + * MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. + * + * Whilst the Work is capable of being deployed, used and adopted (instantiated) to create + * a distributed ledger it is your responsibility to test and validate the code, together + * with all logic and performance of that code under all foreseeable scenarios. + * + * The Licensor does not make or purport to make and hereby excludes liability for all + * and any representation, warranty or undertaking in any form whatsoever, whether express + * or implied, to any entity or person, including any representation, warranty or + * undertaking, as to the functionality security use, value or other characteristics of + * any distributed ledger nor in respect the functioning or value of any tokens which may + * be created stored or transferred using the Work. The Licensor does not warrant that the + * Work or any use of the Work complies with any law or regulation in any territory where + * it may be implemented or used or that it will be appropriate for any specific purpose. + * + * Neither the licensor nor any current or former employees, officers, directors, partners, + * trustees, representatives, agents, advisors, contractors, or volunteers of the Licensor + * shall be liable for any direct or indirect, special, incidental, consequential or other + * losses of any kind, in tort, contract or otherwise (including but not limited to loss + * of revenue, income or profits, or loss of use or data, or loss of reputation, or loss + * of any economic or other opportunity of whatsoever nature or howsoever arising), arising + * out of or in connection with (without limitation of any use, misuse, of any ledger system + * or use made or its functionality or any performance or operation of any code or protocol + * caused by bugs or programming or logic errors or otherwise); + * + * A. any offer, purchase, holding, use, sale, exchange or transmission of any + * cryptographic keys, tokens or assets created, exchanged, stored or arising from any + * interaction with the Work; + * + * B. any failure in a transmission or loss of any token or assets keys or other digital + * artefacts due to errors in transmission; + * + * C. bugs, hacks, logic errors or faults in the Work or any communication; + * + * D. system software or apparatus including but not limited to losses caused by errors + * in holding or transmitting tokens by any third-party; + * + * E. breaches or failure of security including hacker attacks, loss or disclosure of + * password, loss of private key, unauthorised use or misuse of such passwords or keys; + * + * F. any losses including loss of anticipated savings or other benefits resulting from + * use of the Work or any changes to the Work (however implemented). + * + * You are solely responsible for; testing, validating and evaluation of all operation + * logic, functionality, security and appropriateness of using the Work for any commercial + * or non-commercial purpose and for any reproduction or redistribution by You of the + * Work. You assume all risks associated with Your use of the Work and the exercise of + * permissions under this License. + */ + +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace RadixDlt.NetworkGateway.PostgresIntegration.Migrations +{ + /// + public partial class GenerateOrderedIndexForResourceHolders : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_resource_holders_resource_entity_id_balance_id", + table: "resource_holders"); + + migrationBuilder.CreateIndex( + name: "IX_resource_holders_resource_entity_id_balance_entity_id", + table: "resource_holders", + columns: new[] { "resource_entity_id", "balance", "entity_id" }, + descending: new[] { false, true, true }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_resource_holders_resource_entity_id_balance_entity_id", + table: "resource_holders"); + + migrationBuilder.CreateIndex( + name: "IX_resource_holders_resource_entity_id_balance_id", + table: "resource_holders", + columns: new[] { "resource_entity_id", "balance", "id" }); + } + } +} diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql index d8708b76e..37003d1a6 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql @@ -1566,3 +1566,29 @@ BEGIN END $EF$; COMMIT; +START TRANSACTION; + + +DO $EF$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20250113104233_GenerateOrderedIndexForResourceHolders') THEN + DROP INDEX "IX_resource_holders_resource_entity_id_balance_id"; + END IF; +END $EF$; + +DO $EF$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20250113104233_GenerateOrderedIndexForResourceHolders') THEN + CREATE INDEX "IX_resource_holders_resource_entity_id_balance_entity_id" ON resource_holders (resource_entity_id, balance DESC, entity_id DESC); + END IF; +END $EF$; + +DO $EF$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20250113104233_GenerateOrderedIndexForResourceHolders') THEN + INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") + VALUES ('20250113104233_GenerateOrderedIndexForResourceHolders', '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 c60344736..b161d18c6 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs @@ -1760,7 +1760,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("EntityId", "ResourceEntityId") .IsUnique(); - b.HasIndex("ResourceEntityId", "Balance", "Id"); + b.HasIndex("ResourceEntityId", "Balance", "EntityId") + .IsDescending(false, true, true); b.ToTable("resource_holders"); }); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ResourceHoldersQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ResourceHoldersQuerier.cs index 93f7239c0..fe2cfa89f 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ResourceHoldersQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ResourceHoldersQuerier.cs @@ -120,6 +120,10 @@ public ResourceHoldersQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapper limit = limit + 1, }; + // Make sure to use option 1. + // 1. ORDER BY rh.balance DESC, rh.entity_id DESC + // 2. ORDER BY (rh.balance, rh.entity_id) DESC + // As second option resulted in very bad performance (it didn't use index at all, even though both fields were indexed). var cd = DapperExtensions.CreateCommandDefinition( @" SELECT @@ -131,8 +135,8 @@ FROM resource_holders rh INNER JOIN entities e ON rh.entity_id = e.id WHERE rh.resource_entity_id = @resourceEntityId - AND (rh.balance, rh.id) <= (Cast(@balanceBoundary AS numeric(1000,0)), @idBoundary) -ORDER BY rh.balance DESC, rh.id DESC + AND (rh.balance, rh.entity_id) <= (Cast(@balanceBoundary AS numeric(1000,0)), @idBoundary) +ORDER BY rh.balance DESC, rh.entity_id DESC LIMIT @limit", parameters, cancellationToken: token