From bf7a1e84e5efb2276fc4174d7a7a92b3686f8258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Thu, 8 Aug 2024 14:34:28 +0200 Subject: [PATCH 1/6] [data] create a DalCommitments table --- ...48_AddDalCommitmentStatusTable.Designer.cs | 6983 +++++++++++++++++ ...40808123248_AddDalCommitmentStatusTable.cs | 47 + .../Migrations/TzktContextModelSnapshot.cs | 35 + Tzkt.Data/Models/Dal/DalCommitmentStatus.cs | 40 + .../DalPublishCommitmentOperation.cs | 4 + Tzkt.Data/TzktContext.cs | 4 + 6 files changed, 7113 insertions(+) create mode 100644 Tzkt.Data/Migrations/20240808123248_AddDalCommitmentStatusTable.Designer.cs create mode 100644 Tzkt.Data/Migrations/20240808123248_AddDalCommitmentStatusTable.cs create mode 100644 Tzkt.Data/Models/Dal/DalCommitmentStatus.cs diff --git a/Tzkt.Data/Migrations/20240808123248_AddDalCommitmentStatusTable.Designer.cs b/Tzkt.Data/Migrations/20240808123248_AddDalCommitmentStatusTable.Designer.cs new file mode 100644 index 00000000..049be465 --- /dev/null +++ b/Tzkt.Data/Migrations/20240808123248_AddDalCommitmentStatusTable.Designer.cs @@ -0,0 +1,6983 @@ +// +using System; +using System.Numerics; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Tzkt.Data; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + [DbContext(typeof(TzktContext))] + [Migration("20240808123248_AddDalCommitmentStatusTable")] + partial class AddDalCommitmentStatusTable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.18") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveRefutationGamesCount") + .HasColumnType("integer"); + + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + + b.Property("ActiveTokensCount") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character varying(37)"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("ContractsCount") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegationLevel") + .HasColumnType("integer"); + + b.Property("DelegationsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageCount") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("MigrationsCount") + .HasColumnType("integer"); + + b.Property("OriginationsCount") + .HasColumnType("integer"); + + b.Property("RefutationGamesCount") + .HasColumnType("integer"); + + b.Property("RevealsCount") + .HasColumnType("integer"); + + b.Property("RollupBonds") + .HasColumnType("bigint"); + + b.Property("RollupsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesCount") + .HasColumnType("integer"); + + b.Property("SmartRollupBonds") + .HasColumnType("bigint"); + + b.Property("SmartRollupCementCount") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupsCount") + .HasColumnType("integer"); + + b.Property("Staked") + .HasColumnType("boolean"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TransactionsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchCount") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UpdateConsensusKeyCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("DelegateId"); + + b.HasIndex("Extras"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); + + b.HasIndex("FirstLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Type"); + + b.HasIndex("Staked", "Type") + .HasFilter("\"Staked\" = true"); + + b.ToTable("Accounts"); + + b.HasDiscriminator("Type").HasValue((byte)3); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("ActivationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.AppState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountCounter") + .HasColumnType("integer"); + + b.Property("ActivationOpsCount") + .HasColumnType("integer"); + + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + + b.Property("BallotOpsCount") + .HasColumnType("integer"); + + b.Property("BigMapCounter") + .HasColumnType("integer"); + + b.Property("BigMapKeyCounter") + .HasColumnType("integer"); + + b.Property("BigMapUpdateCounter") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Chain") + .HasColumnType("text"); + + b.Property("ChainId") + .HasColumnType("text"); + + b.Property("CommitmentsCount") + .HasColumnType("integer"); + + b.Property("ConstantsCount") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("CyclesCount") + .HasColumnType("integer"); + + b.Property("DalPublishCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("DelegationOpsCount") + .HasColumnType("integer"); + + b.Property("DomainsLevel") + .HasColumnType("integer"); + + b.Property("DomainsNameRegistry") + .HasColumnType("text"); + + b.Property("DoubleBakingOpsCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsementOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardOpsCount") + .HasColumnType("integer"); + + b.Property("EventCounter") + .HasColumnType("integer"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxMessageCounter") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageOpsCount") + .HasColumnType("integer"); + + b.Property("KnownHead") + .HasColumnType("integer"); + + b.Property("LastSync") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerCounter") + .HasColumnType("integer"); + + b.Property("MigrationOpsCount") + .HasColumnType("integer"); + + b.Property("NextProtocol") + .HasColumnType("text"); + + b.Property("NonceRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("OperationCounter") + .HasColumnType("bigint"); + + b.Property("OriginationOpsCount") + .HasColumnType("integer"); + + b.Property("PendingDelegateParameters") + .HasColumnType("integer"); + + b.Property("PreendorsementOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("ProtocolsCount") + .HasColumnType("integer"); + + b.Property("QuoteBtc") + .HasColumnType("double precision"); + + b.Property("QuoteCny") + .HasColumnType("double precision"); + + b.Property("QuoteEth") + .HasColumnType("double precision"); + + b.Property("QuoteEur") + .HasColumnType("double precision"); + + b.Property("QuoteGbp") + .HasColumnType("double precision"); + + b.Property("QuoteJpy") + .HasColumnType("double precision"); + + b.Property("QuoteKrw") + .HasColumnType("double precision"); + + b.Property("QuoteLevel") + .HasColumnType("integer"); + + b.Property("QuoteUsd") + .HasColumnType("double precision"); + + b.Property("RefutationGameCounter") + .HasColumnType("integer"); + + b.Property("RegisterConstantOpsCount") + .HasColumnType("integer"); + + b.Property("RevealOpsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltyOpsCount") + .HasColumnType("integer"); + + b.Property("ScriptCounter") + .HasColumnType("integer"); + + b.Property("SetDelegateParametersOpsCount") + .HasColumnType("integer"); + + b.Property("SetDepositsLimitOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCementOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentCounter") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteOpsCount") + .HasColumnType("integer"); + + b.Property("StakingOpsCount") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("StorageCounter") + .HasColumnType("integer"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TransactionOpsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchOpsCount") + .HasColumnType("integer"); + + b.Property("UnstakeRequestsCount") + .HasColumnType("integer"); + + b.Property("UpdateConsensusKeyOpsCount") + .HasColumnType("integer"); + + b.Property("VdfRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("VotingEpoch") + .HasColumnType("integer"); + + b.Property("VotingPeriod") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("AppState"); + + b.HasData( + new + { + Id = -1, + AccountCounter = 0, + ActivationOpsCount = 0, + AutostakingOpsCount = 0, + BallotOpsCount = 0, + BigMapCounter = 0, + BigMapKeyCounter = 0, + BigMapUpdateCounter = 0, + BlocksCount = 0, + CommitmentsCount = 0, + ConstantsCount = 0, + Cycle = -1, + CyclesCount = 0, + DalPublishCommitmentOpsCount = 0, + DelegationOpsCount = 0, + DomainsLevel = 0, + DoubleBakingOpsCount = 0, + DoubleEndorsingOpsCount = 0, + DoublePreendorsingOpsCount = 0, + DrainDelegateOpsCount = 0, + EndorsementOpsCount = 0, + EndorsingRewardOpsCount = 0, + EventCounter = 0, + EventsCount = 0, + Hash = "", + InboxMessageCounter = 0, + IncreasePaidStorageOpsCount = 0, + KnownHead = 0, + LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Level = -1, + ManagerCounter = 0, + MigrationOpsCount = 0, + NextProtocol = "", + NonceRevelationOpsCount = 0, + OperationCounter = 0L, + OriginationOpsCount = 0, + PendingDelegateParameters = 0, + PreendorsementOpsCount = 0, + ProposalOpsCount = 0, + ProposalsCount = 0, + Protocol = "", + ProtocolsCount = 0, + QuoteBtc = 0.0, + QuoteCny = 0.0, + QuoteEth = 0.0, + QuoteEur = 0.0, + QuoteGbp = 0.0, + QuoteJpy = 0.0, + QuoteKrw = 0.0, + QuoteLevel = -1, + QuoteUsd = 0.0, + RefutationGameCounter = 0, + RegisterConstantOpsCount = 0, + RevealOpsCount = 0, + RevelationPenaltyOpsCount = 0, + ScriptCounter = 0, + SetDelegateParametersOpsCount = 0, + SetDepositsLimitOpsCount = 0, + SmartRollupAddMessagesOpsCount = 0, + SmartRollupCementOpsCount = 0, + SmartRollupCommitmentCounter = 0, + SmartRollupExecuteOpsCount = 0, + SmartRollupOriginateOpsCount = 0, + SmartRollupPublishOpsCount = 0, + SmartRollupRecoverBondOpsCount = 0, + SmartRollupRefuteOpsCount = 0, + StakingOpsCount = 0, + StakingUpdatesCount = 0, + StorageCounter = 0, + TicketBalancesCount = 0, + TicketTransfersCount = 0, + TicketsCount = 0, + Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + TokenBalancesCount = 0, + TokenTransfersCount = 0, + TokensCount = 0, + TransactionOpsCount = 0, + TransferTicketOpsCount = 0, + TxRollupCommitOpsCount = 0, + TxRollupDispatchTicketsOpsCount = 0, + TxRollupFinalizeCommitmentOpsCount = 0, + TxRollupOriginationOpsCount = 0, + TxRollupRejectionOpsCount = 0, + TxRollupRemoveCommitmentOpsCount = 0, + TxRollupReturnBondOpsCount = 0, + TxRollupSubmitBatchOpsCount = 0, + UnstakeRequestsCount = 0, + UpdateConsensusKeyOpsCount = 0, + VdfRevelationOpsCount = 0, + VotingEpoch = -1, + VotingPeriod = -1 + }); + }); + + modelBuilder.Entity("Tzkt.Data.Models.AutostakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("AutostakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("BakingPower") + .HasColumnType("bigint"); + + b.Property("BlockFees") + .HasColumnType("bigint"); + + b.Property("BlockRewardsDelegated") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedEdge") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("BlockRewardsStakedShared") + .HasColumnType("bigint"); + + b.Property("Blocks") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingLostExternalStaked") + .HasColumnType("bigint"); + + b.Property("DoubleBakingLostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("DoubleBakingLostStaked") + .HasColumnType("bigint"); + + b.Property("DoubleBakingLostUnstaked") + .HasColumnType("bigint"); + + b.Property("DoubleBakingRewards") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLostExternalStaked") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLostStaked") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLostUnstaked") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingRewards") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLostExternalStaked") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLostStaked") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLostUnstaked") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingRewards") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsDelegated") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedEdge") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardsStakedShared") + .HasColumnType("bigint"); + + b.Property("Endorsements") + .HasColumnType("integer"); + + b.Property("ExpectedBlocks") + .HasColumnType("double precision"); + + b.Property("ExpectedEndorsements") + .HasColumnType("double precision"); + + b.Property("ExternalDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("FutureBlockRewards") + .HasColumnType("bigint"); + + b.Property("FutureBlocks") + .HasColumnType("integer"); + + b.Property("FutureEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("FutureEndorsements") + .HasColumnType("integer"); + + b.Property("MissedBlockFees") + .HasColumnType("bigint"); + + b.Property("MissedBlockRewards") + .HasColumnType("bigint"); + + b.Property("MissedBlocks") + .HasColumnType("integer"); + + b.Property("MissedEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("MissedEndorsements") + .HasColumnType("integer"); + + b.Property("NonceRevelationLosses") + .HasColumnType("bigint"); + + b.Property("NonceRevelationRewardsDelegated") + .HasColumnType("bigint"); + + b.Property("NonceRevelationRewardsStakedEdge") + .HasColumnType("bigint"); + + b.Property("NonceRevelationRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("NonceRevelationRewardsStakedShared") + .HasColumnType("bigint"); + + b.Property("OwnDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); + + b.Property("StakersCount") + .HasColumnType("integer"); + + b.Property("TotalBakingPower") + .HasColumnType("bigint"); + + b.Property("VdfRevelationRewardsDelegated") + .HasColumnType("bigint"); + + b.Property("VdfRevelationRewardsStakedEdge") + .HasColumnType("bigint"); + + b.Property("VdfRevelationRewardsStakedOwn") + .HasColumnType("bigint"); + + b.Property("VdfRevelationRewardsStakedShared") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle", "BakerId"); + + b.ToTable("BakerCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Round") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("Cycle", "BakerId"); + + b.ToTable("BakingRights"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Vote") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("BallotOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("ActiveKeys") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("KeyType") + .HasColumnType("bytea"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Ptr") + .HasColumnType("integer"); + + b.Property("StoragePath") + .HasColumnType("text"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TotalKeys") + .HasColumnType("integer"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.Property("ValueType") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Ptr") + .IsUnique(); + + b.ToTable("BigMaps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("JsonKey") + .HasColumnType("jsonb"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("KeyHash") + .HasMaxLength(54) + .HasColumnType("character(54)") + .IsFixedLength(); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RawKey") + .HasColumnType("bytea"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("JsonKey"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); + + b.HasIndex("JsonValue"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("BigMapPtr", "KeyHash"); + + b.HasIndex(new[] { "BigMapPtr" }, "IX_BigMapKeys_BigMapPtr_Partial") + .HasFilter("\"Active\" = true"); + + b.ToTable("BigMapKeys"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("BigMapKeyId") + .HasColumnType("integer"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" IS NOT NULL"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" IS NOT NULL"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" IS NOT NULL"); + + b.HasIndex("BigMapKeyId", "Id") + .HasFilter("\"BigMapKeyId\" IS NOT NULL"); + + b.HasIndex("BigMapPtr", "Id"); + + b.ToTable("BigMapUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AIToggle") + .HasColumnType("boolean"); + + b.Property("AIToggleEma") + .HasColumnType("integer"); + + b.Property("BlockRound") + .HasColumnType("integer"); + + b.Property("BonusDelegated") + .HasColumnType("bigint"); + + b.Property("BonusStakedEdge") + .HasColumnType("bigint"); + + b.Property("BonusStakedOwn") + .HasColumnType("bigint"); + + b.Property("BonusStakedShared") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Events") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Fees") + .HasColumnType("bigint"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBToggle") + .HasColumnType("boolean"); + + b.Property("LBToggleEma") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Operations") + .HasColumnType("bigint"); + + b.Property("PayloadRound") + .HasColumnType("integer"); + + b.Property("ProducerId") + .HasColumnType("integer"); + + b.Property("ProposerId") + .HasColumnType("integer"); + + b.Property("ProtoCode") + .HasColumnType("integer"); + + b.Property("ResetBakerDeactivation") + .HasColumnType("integer"); + + b.Property("ResetProposerDeactivation") + .HasColumnType("integer"); + + b.Property("RevelationId") + .HasColumnType("bigint"); + + b.Property("RewardDelegated") + .HasColumnType("bigint"); + + b.Property("RewardStakedEdge") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") + .HasColumnType("bigint"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Validations") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("Level") + .IsUnique(); + + b.HasIndex("ProducerId"); + + b.HasIndex("ProposerId"); + + b.HasIndex("ProtoCode"); + + b.HasIndex("RevelationId") + .IsUnique(); + + b.HasIndex("SoftwareId"); + + b.ToTable("Blocks"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character(37)") + .IsFixedLength(); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Address") + .IsUnique(); + + b.ToTable("Commitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("JsonPayload") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RawPayload") + .HasColumnType("bytea"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("JsonPayload"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("Tag"); + + b.HasIndex("TransactionId"); + + b.HasIndex("ContractCodeHash", "Tag"); + + b.HasIndex("ContractId", "Tag"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlockBonusPerSlot") + .HasColumnType("bigint"); + + b.Property("BlockReward") + .HasColumnType("bigint"); + + b.Property("EndorsementRewardPerSlot") + .HasColumnType("bigint"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("MaxBlockReward") + .HasColumnType("bigint"); + + b.Property("NonceRevelationReward") + .HasColumnType("bigint"); + + b.Property("Seed") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("SnapshotLevel") + .HasColumnType("integer"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalBakingPower") + .HasColumnType("bigint"); + + b.Property("VdfRevelationReward") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("Cycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalCommitmentStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("PublishmentId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PublishmentId") + .IsUnique(); + + b.ToTable("DalCommitmentStatus"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalPublishCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Commitment") + .HasColumnType("text"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Slot") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("DalPublishCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevDelegateId") + .HasColumnType("integer"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("PrevDelegateId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId", "Id"); + + b.ToTable("DelegationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorId") + .HasColumnType("integer"); + + b.Property("StakedBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DelegatorId"); + + b.HasIndex("Cycle", "BakerId"); + + b.HasIndex("Cycle", "DelegatorId"); + + b.ToTable("DelegatorCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Domain", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("jsonb"); + + b.Property("Expiration") + .HasColumnType("timestamp with time zone"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("Reverse") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("Address"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Level"); + + b.HasIndex("Name"); + + b.HasIndex("Owner"); + + b.ToTable("Domains"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("LostStaked") + .HasColumnType("bigint"); + + b.Property("LostUnstaked") + .HasColumnType("bigint"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleBakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("LostStaked") + .HasColumnType("bigint"); + + b.Property("LostUnstaked") + .HasColumnType("bigint"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleEndorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LostExternalStaked") + .HasColumnType("bigint"); + + b.Property("LostExternalUnstaked") + .HasColumnType("bigint"); + + b.Property("LostStaked") + .HasColumnType("bigint"); + + b.Property("LostUnstaked") + .HasColumnType("bigint"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SlashedLevel") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoublePreendorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Fee") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("TargetId"); + + b.ToTable("DrainDelegateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DalAttestation") + .HasColumnType("numeric"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("EndorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Expected") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RewardDelegated") + .HasColumnType("bigint"); + + b.Property("RewardStakedEdge") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") + .HasColumnType("bigint"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("EndorsingRewardOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OperationId") + .HasColumnType("bigint"); + + b.Property("Payload") + .HasColumnType("bytea"); + + b.Property("PredecessorLevel") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OperationId"); + + b.HasIndex("Type", "Id"); + + b.ToTable("InboxMessages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("IncreasePaidStorageOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("BalanceChange") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Level"); + + b.HasIndex("ScriptId"); + + b.HasIndex("StorageId"); + + b.ToTable("MigrationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RevealedCycle") + .HasColumnType("integer"); + + b.Property("RevealedLevel") + .HasColumnType("integer"); + + b.Property("RewardDelegated") + .HasColumnType("bigint"); + + b.Property("RewardStakedEdge") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RevealedCycle"); + + b.HasIndex("SenderId"); + + b.ToTable("NonceRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash") + .HasFilter("\"ContractCodeHash\" IS NOT NULL"); + + b.HasIndex("ContractId"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("ManagerId"); + + b.HasIndex("OpHash"); + + b.HasIndex("ScriptId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.ToTable("OriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("PreendorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstPeriod") + .HasColumnType("integer"); + + b.Property("Hash") + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastPeriod") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Upvotes") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("FirstPeriod"); + + b.HasIndex("Hash"); + + b.HasIndex("LastPeriod"); + + b.HasIndex(new[] { "Status" }, "IX_Proposals_Status_Partial") + .HasFilter("\"Status\" = 0"); + + b.ToTable("Proposals"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Duplicated") + .HasColumnType("boolean"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("ProposalOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotQuorumMax") + .HasColumnType("integer"); + + b.Property("BallotQuorumMin") + .HasColumnType("integer"); + + b.Property("BlockDeposit") + .HasColumnType("bigint"); + + b.Property("BlockReward0") + .HasColumnType("bigint"); + + b.Property("BlockReward1") + .HasColumnType("bigint"); + + b.Property("BlocksPerCommitment") + .HasColumnType("integer"); + + b.Property("BlocksPerCycle") + .HasColumnType("integer"); + + b.Property("BlocksPerSnapshot") + .HasColumnType("integer"); + + b.Property("BlocksPerVoting") + .HasColumnType("integer"); + + b.Property("ByteCost") + .HasColumnType("integer"); + + b.Property("Code") + .HasColumnType("integer"); + + b.Property("ConsensusRightsDelay") + .HasColumnType("integer"); + + b.Property("ConsensusThreshold") + .HasColumnType("integer"); + + b.Property("DalAttestationLag") + .HasColumnType("integer"); + + b.Property("DalAttestationThreshold") + .HasColumnType("integer"); + + b.Property("DalShardsPerSlot") + .HasColumnType("integer"); + + b.Property("DalSlotsPerLevel") + .HasColumnType("integer"); + + b.Property("DelegateParametersActivationDelay") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("text"); + + b.Property("DoubleBakingSlashedPercentage") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingSlashedPercentage") + .HasColumnType("integer"); + + b.Property("EndorsementDeposit") + .HasColumnType("bigint"); + + b.Property("EndorsementReward0") + .HasColumnType("bigint"); + + b.Property("EndorsementReward1") + .HasColumnType("bigint"); + + b.Property("EndorsersPerBlock") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstCycle") + .HasColumnType("integer"); + + b.Property("FirstCycleLevel") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("HardBlockGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationStorageLimit") + .HasColumnType("integer"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBToggleThreshold") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("MaxBakingReward") + .HasColumnType("bigint"); + + b.Property("MaxDelegatedOverFrozenRatio") + .HasColumnType("integer"); + + b.Property("MaxEndorsingReward") + .HasColumnType("bigint"); + + b.Property("MaxExternalOverOwnStakeRatio") + .HasColumnType("integer"); + + b.Property("MaxSlashingPeriod") + .HasColumnType("integer"); + + b.Property("MinParticipationDenominator") + .HasColumnType("integer"); + + b.Property("MinParticipationNumerator") + .HasColumnType("integer"); + + b.Property("MinimalFrozenStake") + .HasColumnType("bigint"); + + b.Property("MinimalStake") + .HasColumnType("bigint"); + + b.Property("NoRewardCycles") + .HasColumnType("integer"); + + b.Property("OriginationSize") + .HasColumnType("integer"); + + b.Property("ProposalQuorum") + .HasColumnType("integer"); + + b.Property("RampUpCycles") + .HasColumnType("integer"); + + b.Property("SmartRollupChallengeWindow") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentPeriod") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginationSize") + .HasColumnType("integer"); + + b.Property("SmartRollupStakeAmount") + .HasColumnType("bigint"); + + b.Property("SmartRollupTimeoutPeriod") + .HasColumnType("integer"); + + b.Property("StakePowerMultiplier") + .HasColumnType("integer"); + + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); + + b.Property("Version") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Code") + .IsUnique(); + + b.HasIndex("Hash") + .IsUnique(); + + b.ToTable("Protocols"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Btc") + .HasColumnType("double precision"); + + b.Property("Cny") + .HasColumnType("double precision"); + + b.Property("Eth") + .HasColumnType("double precision"); + + b.Property("Eur") + .HasColumnType("double precision"); + + b.Property("Gbp") + .HasColumnType("double precision"); + + b.Property("Jpy") + .HasColumnType("double precision"); + + b.Property("Krw") + .HasColumnType("double precision"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Usd") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("InitiatorCommitmentId") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InitiatorLoss") + .HasColumnType("bigint"); + + b.Property("InitiatorReward") + .HasColumnType("bigint"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("LastMoveId") + .HasColumnType("bigint"); + + b.Property("OpponentCommitmentId") + .HasColumnType("integer"); + + b.Property("OpponentId") + .HasColumnType("integer"); + + b.Property("OpponentLoss") + .HasColumnType("bigint"); + + b.Property("OpponentReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("InitiatorCommitmentId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("LastLevel"); + + b.HasIndex("OpponentCommitmentId"); + + b.HasIndex("OpponentId"); + + b.HasIndex("SmartRollupId", "Id"); + + b.ToTable("RefutationGames"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Refs") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Value") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .HasFilter("\"Address\" IS NOT NULL"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RegisterConstantOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RevealOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("MissedLevel") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("RevelationPenaltyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Script", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CodeSchema") + .HasColumnType("bytea"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ParameterSchema") + .HasColumnType("bytea"); + + b.Property("StorageSchema") + .HasColumnType("bytea"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("Views") + .HasColumnType("bytea[]"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "ContractId" }, "IX_Scripts_ContractId_Partial") + .HasFilter("\"Current\" = true"); + + b.ToTable("Scripts"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDelegateParametersOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ActivationCycle"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId", "Id"); + + b.ToTable("SetDelegateParametersOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Limit") + .HasColumnType("numeric"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId", "Id"); + + b.ToTable("SetDepositsLimitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MessagesCount") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupAddMessagesOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId", "Id"); + + b.ToTable("SmartRollupCementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("PredecessorId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Stakers") + .HasColumnType("integer"); + + b.Property("State") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Successors") + .HasColumnType("integer"); + + b.Property("Ticks") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("InboxLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("PredecessorId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("Hash", "SmartRollupId"); + + b.ToTable("SmartRollupCommitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("CommitmentId", "Id"); + + b.ToTable("SmartRollupExecuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("Kernel") + .HasColumnType("bytea"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ParameterType") + .HasColumnType("bytea"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupOriginateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("BondStatus") + .HasColumnType("integer"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Flags") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId", "BondStatus", "SenderId") + .HasFilter("\"BondStatus\" IS NOT NULL"); + + b.HasIndex("SmartRollupId", "SenderId", "Id"); + + b.ToTable("SmartRollupPublishOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("StakerId"); + + b.ToTable("SmartRollupRecoverBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DissectionEnd") + .HasColumnType("bigint"); + + b.Property("DissectionStart") + .HasColumnType("bigint"); + + b.Property("DissectionSteps") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GameId") + .HasColumnType("integer"); + + b.Property("GameStatus") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Move") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("GameId", "Id"); + + b.ToTable("SmartRollupRefuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("ExternalDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OwnDelegatedBalance") + .HasColumnType("bigint"); + + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); + + b.Property("StakersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Level", "AccountId", "BakerId"); + + b.HasIndex(new[] { "Level" }, "IX_SnapshotBalances_Level_Partial") + .HasFilter("\"AccountId\" = \"BakerId\""); + + b.ToTable("SnapshotBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Software", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("ShortHash") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character(8)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.ToTable("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.StakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RequestedAmount") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("StakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.StakingUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("AutostakingOpId") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegationOpId") + .HasColumnType("bigint"); + + b.Property("DoubleBakingOpId") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingOpId") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingOpId") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Pseudotokens") + .HasColumnType("numeric"); + + b.Property("RoundingError") + .HasColumnType("bigint"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("StakingOpId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AutostakingOpId") + .HasFilter("\"AutostakingOpId\" IS NOT NULL"); + + b.HasIndex("DelegationOpId") + .HasFilter("\"DelegationOpId\" IS NOT NULL"); + + b.HasIndex("DoubleBakingOpId") + .HasFilter("\"DoubleBakingOpId\" IS NOT NULL"); + + b.HasIndex("DoubleEndorsingOpId") + .HasFilter("\"DoubleEndorsingOpId\" IS NOT NULL"); + + b.HasIndex("DoublePreendorsingOpId") + .HasFilter("\"DoublePreendorsingOpId\" IS NOT NULL"); + + b.HasIndex("StakingOpId") + .HasFilter("\"StakingOpId\" IS NOT NULL"); + + b.HasIndex("Level", "Id"); + + b.HasIndex("BakerId", "Cycle", "Id"); + + b.HasIndex("StakerId", "Cycle", "Id"); + + b.ToTable("StakingUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("TotalActivated") + .HasColumnType("bigint"); + + b.Property("TotalBanished") + .HasColumnType("bigint"); + + b.Property("TotalBootstrapped") + .HasColumnType("bigint"); + + b.Property("TotalBurned") + .HasColumnType("bigint"); + + b.Property("TotalCommitments") + .HasColumnType("bigint"); + + b.Property("TotalCreated") + .HasColumnType("bigint"); + + b.Property("TotalFrozen") + .HasColumnType("bigint"); + + b.Property("TotalLost") + .HasColumnType("bigint"); + + b.Property("TotalRollupBonds") + .HasColumnType("bigint"); + + b.Property("TotalSmartRollupBonds") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle") + .IsUnique() + .HasFilter("\"Cycle\" IS NOT NULL"); + + b.HasIndex("Date") + .IsUnique() + .HasFilter("\"Date\" IS NOT NULL"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Statistics"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Storage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("ContractId", "Id"); + + b.HasIndex(new[] { "ContractId" }, "IX_Storages_ContractId_Partial") + .HasFilter("\"Current\" = true"); + + b.ToTable("Storages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContentHash") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("jsonb"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TotalBurned") + .HasColumnType("numeric"); + + b.Property("TotalMinted") + .HasColumnType("numeric"); + + b.Property("TotalSupply") + .HasColumnType("numeric"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContentHash"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("JsonContent"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonContent"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonContent"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("TypeHash"); + + b.HasIndex("TicketerId", "TypeHash", "ContentHash"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("numeric"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("TicketId"); + + b.HasIndex("TicketerId"); + + b.HasIndex("AccountId", "TicketId") + .IsUnique(); + + b.HasIndex("AccountId", "TicketerId"); + + b.ToTable("TicketBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("TransferTicketId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("FromId"); + + b.HasIndex("SmartRollupExecuteId") + .HasFilter("\"SmartRollupExecuteId\" IS NOT NULL"); + + b.HasIndex("TicketId"); + + b.HasIndex("TicketerId"); + + b.HasIndex("ToId"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" IS NOT NULL"); + + b.HasIndex("TransferTicketId") + .HasFilter("\"TransferTicketId\" IS NOT NULL"); + + b.HasIndex("Level", "Id"); + + b.ToTable("TicketTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Token", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("numeric"); + + b.Property("TotalBurned") + .HasColumnType("numeric"); + + b.Property("TotalMinted") + .HasColumnType("numeric"); + + b.Property("TotalSupply") + .HasColumnType("numeric"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" IS NOT NULL"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("ContractId", "TokenId") + .IsUnique(); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("numeric"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" IS NOT NULL"); + + b.HasIndex("LastLevel"); + + b.HasIndex("TokenId"); + + b.HasIndex("AccountId", "ContractId"); + + b.HasIndex("AccountId", "TokenId") + .IsUnique(); + + b.HasIndex(new[] { "AccountId" }, "IX_TokenBalances_AccountId_Partial") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex(new[] { "ContractId" }, "IX_TokenBalances_ContractId_Partial") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex(new[] { "TokenId" }, "IX_TokenBalances_TokenId_Partial") + .HasFilter("\"Balance\" != '0'"); + + b.ToTable("TokenBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" IS NOT NULL"); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" IS NOT NULL"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" IS NOT NULL"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" IS NOT NULL"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" IS NOT NULL"); + + b.HasIndex("TokenId"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" IS NOT NULL"); + + b.HasIndex("Level", "Id"); + + b.ToTable("TokenTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InternalDelegations") + .HasColumnType("smallint"); + + b.Property("InternalOperations") + .HasColumnType("smallint"); + + b.Property("InternalOriginations") + .HasColumnType("smallint"); + + b.Property("InternalTransactions") + .HasColumnType("smallint"); + + b.Property("JsonParameters") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawParameters") + .HasColumnType("bytea"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetCodeHash") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("JsonParameters"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.HasIndex("TargetCodeHash") + .HasFilter("\"TargetCodeHash\" IS NOT NULL"); + + b.HasIndex("TargetId"); + + b.HasIndex(new[] { "TargetId" }, "IX_TransactionOps_TargetId_Partial") + .HasFilter("\"Entrypoint\" = 'transfer'\nAND \"TokenTransfers\" IS NULL\nAND \"Status\" = 1"); + + b.ToTable("TransactionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("TargetId"); + + b.HasIndex("TicketerId"); + + b.ToTable("TransferTicketOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupCommitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupDispatchTicketsOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupFinalizeCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupOriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitterId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitterId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRejectionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRemoveCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupReturnBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupSubmitBatchOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UnstakeRequest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("FinalizedAmount") + .HasColumnType("bigint"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RequestedAmount") + .HasColumnType("bigint"); + + b.Property("RestakedAmount") + .HasColumnType("bigint"); + + b.Property("RoundingError") + .HasColumnType("bigint"); + + b.Property("SlashedAmount") + .HasColumnType("bigint"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("UpdatesCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BakerId", "Cycle"); + + b.HasIndex("StakerId", "Cycle"); + + b.ToTable("UnstakeRequests"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("PublicKeyHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("UpdateConsensusKeyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Proof") + .HasColumnType("bytea"); + + b.Property("RewardDelegated") + .HasColumnType("bigint"); + + b.Property("RewardStakedEdge") + .HasColumnType("bigint"); + + b.Property("RewardStakedOwn") + .HasColumnType("bigint"); + + b.Property("RewardStakedShared") + .HasColumnType("bigint"); + + b.Property("Solution") + .HasColumnType("bytea"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Cycle", "Id"); + + b.ToTable("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotsQuorum") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("integer"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("NayBallots") + .HasColumnType("integer"); + + b.Property("NayVotingPower") + .HasColumnType("bigint"); + + b.Property("ParticipationEma") + .HasColumnType("integer"); + + b.Property("PassBallots") + .HasColumnType("integer"); + + b.Property("PassVotingPower") + .HasColumnType("bigint"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("SingleWinner") + .HasColumnType("boolean"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Supermajority") + .HasColumnType("integer"); + + b.Property("TopUpvotes") + .HasColumnType("integer"); + + b.Property("TopVotingPower") + .HasColumnType("bigint"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalVotingPower") + .HasColumnType("bigint"); + + b.Property("UpvotesQuorum") + .HasColumnType("integer"); + + b.Property("YayBallots") + .HasColumnType("integer"); + + b.Property("YayVotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("VotingPeriods"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Period", "BakerId") + .IsUnique(); + + b.ToTable("VotingSnapshots"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("smallint"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Spendable") + .HasColumnType("boolean"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("WeirdDelegateId") + .HasColumnType("integer"); + + b.HasIndex("CodeHash"); + + b.HasIndex("CreatorId"); + + b.HasIndex("ManagerId"); + + b.HasIndex("TypeHash"); + + b.HasIndex("WeirdDelegateId") + .HasFilter("\"WeirdDelegateId\" IS NOT NULL"); + + b.HasIndex(new[] { "Kind" }, "IX_Accounts_Kind_Partial") + .HasFilter("\"Type\" = 2"); + + b.HasDiscriminator().HasValue((byte)2); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)4); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("CementedCommitments") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("ExecutedCommitments") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("LastCommitment") + .HasColumnType("text"); + + b.Property("OrphanCommitments") + .HasColumnType("integer"); + + b.Property("ParameterSchema") + .HasColumnType("bytea"); + + b.Property("PendingCommitments") + .HasColumnType("integer"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("RefutedCommitments") + .HasColumnType("integer"); + + b.Property("TotalStakers") + .HasColumnType("integer"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)5); + }); + + modelBuilder.Entity("Tzkt.Data.Models.User", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("ActivationsCount") + .HasColumnType("integer"); + + b.Property("DalPublishCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("RegisterConstantsCount") + .HasColumnType("integer"); + + b.Property("Revealed") + .HasColumnType("boolean"); + + b.Property("SetDelegateParametersOpsCount") + .HasColumnType("integer"); + + b.Property("SetDepositsLimitsCount") + .HasColumnType("integer"); + + b.Property("StakedPseudotokens") + .HasColumnType("numeric"); + + b.Property("StakingOpsCount") + .HasColumnType("integer"); + + b.Property("StakingUpdatesCount") + .HasColumnType("integer"); + + b.Property("UnstakedBakerId") + .HasColumnType("integer"); + + b.Property("UnstakedBalance") + .HasColumnType("bigint"); + + b.HasIndex("UnstakedBakerId") + .HasFilter("\"UnstakedBakerId\" IS NOT NULL"); + + b.HasDiscriminator().HasValue((byte)0); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasBaseType("Tzkt.Data.Models.User"); + + b.Property("ActivationLevel") + .HasColumnType("integer"); + + b.Property("AutostakingOpsCount") + .HasColumnType("integer"); + + b.Property("BallotsCount") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("DeactivationLevel") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingCount") + .HasColumnType("integer"); + + b.Property("EdgeOfBakingOverStaking") + .HasColumnType("bigint"); + + b.Property("EndorsementsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardsCount") + .HasColumnType("integer"); + + b.Property("ExternalStakedBalance") + .HasColumnType("bigint"); + + b.Property("ExternalUnstakedBalance") + .HasColumnType("bigint"); + + b.Property("FrozenDepositLimit") + .HasColumnType("bigint"); + + b.Property("IssuedPseudotokens") + .HasColumnType("numeric"); + + b.Property("LimitOfStakingOverBaking") + .HasColumnType("bigint"); + + b.Property("NonceRevelationsCount") + .HasColumnType("integer"); + + b.Property("OwnStakedBalance") + .HasColumnType("bigint"); + + b.Property("PreendorsementsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltiesCount") + .HasColumnType("integer"); + + b.Property("RoundingError") + .HasColumnType("bigint"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("StakersCount") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.Property("VdfRevelationsCount") + .HasColumnType("integer"); + + b.HasIndex("SoftwareId"); + + b.HasIndex(new[] { "DeactivationLevel" }, "IX_Accounts_DeactivationLevel_Partial") + .HasFilter("\"Type\" = 1"); + + b.HasIndex(new[] { "Staked" }, "IX_Accounts_Staked_Partial") + .HasFilter("\"Type\" = 1"); + + b.HasDiscriminator().HasValue((byte)1); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany("DelegatedAccounts") + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") + .WithMany("CreatedAccounts") + .HasForeignKey("FirstLevel") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Delegate"); + + b.Navigation("FirstBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.HasOne("Tzkt.Data.Models.User", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Activations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Ballots") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") + .WithMany() + .HasForeignKey("ProposerId"); + + b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") + .WithMany() + .HasForeignKey("ProtoCode") + .HasPrincipalKey("Code") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") + .WithOne("RevealedBlock") + .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); + + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Proposer"); + + b.Navigation("Protocol"); + + b.Navigation("Revelation"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalCommitmentStatus", b => + { + b.HasOne("Tzkt.Data.Models.DalPublishCommitmentOperation", "Publishment") + .WithOne("DalCommitmentStatus") + .HasForeignKey("Tzkt.Data.Models.DalCommitmentStatus", "PublishmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Publishment"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalPublishCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DalPublishCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Delegations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") + .WithMany() + .HasForeignKey("PrevDelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("PrevDelegate"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleBakings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleEndorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoublePreendorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DrainDelegateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Endorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("IncreasePaidStorageOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Migrations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Account"); + + b.Navigation("Block"); + + b.Navigation("Script"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Revelations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Contract", "Contract") + .WithMany() + .HasForeignKey("ContractId"); + + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Originations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Block"); + + b.Navigation("Contract"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("Manager"); + + b.Navigation("Script"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Preendorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Proposals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RegisterConstants") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Reveals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RevelationPenalties") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDelegateParametersOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SetDelegateParametersOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SetDepositsLimits") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupAddMessagesOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupCementOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupExecuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupOriginateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupPublishOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRecoverBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRefuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.StakingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("StakingOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Transactions") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.HasOne("Tzkt.Data.Models.Account", "Target") + .WithMany() + .HasForeignKey("TargetId"); + + b.Navigation("Block"); + + b.Navigation("Initiator"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TransferTicketOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupCommitOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupDispatchTicketsOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupFinalizeCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupOriginationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRejectionOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRemoveCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupReturnBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupSubmitBatchOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("UpdateConsensusKeyOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("VdfRevelationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Creator") + .WithMany() + .HasForeignKey("CreatorId"); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") + .WithMany() + .HasForeignKey("WeirdDelegateId"); + + b.Navigation("Creator"); + + b.Navigation("Manager"); + + b.Navigation("WeirdDelegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Navigation("Activations"); + + b.Navigation("Ballots"); + + b.Navigation("CreatedAccounts"); + + b.Navigation("DalPublishCommitmentOps"); + + b.Navigation("Delegations"); + + b.Navigation("DoubleBakings"); + + b.Navigation("DoubleEndorsings"); + + b.Navigation("DoublePreendorsings"); + + b.Navigation("DrainDelegateOps"); + + b.Navigation("Endorsements"); + + b.Navigation("IncreasePaidStorageOps"); + + b.Navigation("Migrations"); + + b.Navigation("Originations"); + + b.Navigation("Preendorsements"); + + b.Navigation("Proposals"); + + b.Navigation("RegisterConstants"); + + b.Navigation("Reveals"); + + b.Navigation("RevelationPenalties"); + + b.Navigation("Revelations"); + + b.Navigation("SetDelegateParametersOps"); + + b.Navigation("SetDepositsLimits"); + + b.Navigation("SmartRollupAddMessagesOps"); + + b.Navigation("SmartRollupCementOps"); + + b.Navigation("SmartRollupExecuteOps"); + + b.Navigation("SmartRollupOriginateOps"); + + b.Navigation("SmartRollupPublishOps"); + + b.Navigation("SmartRollupRecoverBondOps"); + + b.Navigation("SmartRollupRefuteOps"); + + b.Navigation("StakingOps"); + + b.Navigation("Transactions"); + + b.Navigation("TransferTicketOps"); + + b.Navigation("TxRollupCommitOps"); + + b.Navigation("TxRollupDispatchTicketsOps"); + + b.Navigation("TxRollupFinalizeCommitmentOps"); + + b.Navigation("TxRollupOriginationOps"); + + b.Navigation("TxRollupRejectionOps"); + + b.Navigation("TxRollupRemoveCommitmentOps"); + + b.Navigation("TxRollupReturnBondOps"); + + b.Navigation("TxRollupSubmitBatchOps"); + + b.Navigation("UpdateConsensusKeyOps"); + + b.Navigation("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DalPublishCommitmentOperation", b => + { + b.Navigation("DalCommitmentStatus"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Navigation("RevealedBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.Navigation("DelegatedAccounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Tzkt.Data/Migrations/20240808123248_AddDalCommitmentStatusTable.cs b/Tzkt.Data/Migrations/20240808123248_AddDalCommitmentStatusTable.cs new file mode 100644 index 00000000..dd1ec3d6 --- /dev/null +++ b/Tzkt.Data/Migrations/20240808123248_AddDalCommitmentStatusTable.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + /// + public partial class AddDalCommitmentStatusTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "DalCommitmentStatus", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + PublishmentId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DalCommitmentStatus", x => x.Id); + table.ForeignKey( + name: "FK_DalCommitmentStatus_DalPublishCommitmentOps_PublishmentId", + column: x => x.PublishmentId, + principalTable: "DalPublishCommitmentOps", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_DalCommitmentStatus_PublishmentId", + table: "DalCommitmentStatus", + column: "PublishmentId", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DalCommitmentStatus"); + } + } +} diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 54cc52a6..a4e1c07e 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -1389,6 +1389,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Cycles"); }); + modelBuilder.Entity("Tzkt.Data.Models.DalCommitmentStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("PublishmentId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("PublishmentId") + .IsUnique(); + + b.ToTable("DalCommitmentStatus"); + }); + modelBuilder.Entity("Tzkt.Data.Models.DalPublishCommitmentOperation", b => { b.Property("Id") @@ -5939,6 +5958,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Software"); }); + modelBuilder.Entity("Tzkt.Data.Models.DalCommitmentStatus", b => + { + b.HasOne("Tzkt.Data.Models.DalPublishCommitmentOperation", "Publishment") + .WithOne("DalCommitmentStatus") + .HasForeignKey("Tzkt.Data.Models.DalCommitmentStatus", "PublishmentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Publishment"); + }); + modelBuilder.Entity("Tzkt.Data.Models.DalPublishCommitmentOperation", b => { b.HasOne("Tzkt.Data.Models.Block", "Block") @@ -6930,6 +6960,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("VdfRevelationOps"); }); + modelBuilder.Entity("Tzkt.Data.Models.DalPublishCommitmentOperation", b => + { + b.Navigation("DalCommitmentStatus"); + }); + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => { b.Navigation("RevealedBlock"); diff --git a/Tzkt.Data/Models/Dal/DalCommitmentStatus.cs b/Tzkt.Data/Models/Dal/DalCommitmentStatus.cs new file mode 100644 index 00000000..57e60463 --- /dev/null +++ b/Tzkt.Data/Models/Dal/DalCommitmentStatus.cs @@ -0,0 +1,40 @@ +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; + +namespace Tzkt.Data.Models +{ + public class DalCommitmentStatus + { + public int Id { get; set; } + public long PublishmentId { get; set; } + + #region relations + [ForeignKey(nameof(PublishmentId))] + public DalPublishCommitmentOperation Publishment { get; set; } + #endregion + } + + public static class DalCommitmentStatusModel + { + public static void BuildDalCommitmentStatusModel(this ModelBuilder modelBuilder) + { + #region keys + modelBuilder.Entity() + .HasKey(x => x.Id); + #endregion + + #region indexes + modelBuilder.Entity() + .HasIndex(x => x.PublishmentId); + #endregion + + #region relations + modelBuilder.Entity() + .HasOne(x => x.Publishment) + .WithOne(x => x.DalCommitmentStatus) + .HasForeignKey(x => x.PublishmentId) + .HasPrincipalKey(x => x.Id); + #endregion + } + } +} diff --git a/Tzkt.Data/Models/Operations/DalPublishCommitmentOperation.cs b/Tzkt.Data/Models/Operations/DalPublishCommitmentOperation.cs index 3c2d24c3..23443fcd 100644 --- a/Tzkt.Data/Models/Operations/DalPublishCommitmentOperation.cs +++ b/Tzkt.Data/Models/Operations/DalPublishCommitmentOperation.cs @@ -7,6 +7,10 @@ public class DalPublishCommitmentOperation : ManagerOperation { public int Slot { get; set; } public string Commitment { get; set; } + + #region indirect relations + public DalCommitmentStatus DalCommitmentStatus { get; set; } + #endregion } public static class DalPublishCommitmentOperationModel diff --git a/Tzkt.Data/TzktContext.cs b/Tzkt.Data/TzktContext.cs index 3b2ad78d..08414ae0 100644 --- a/Tzkt.Data/TzktContext.cs +++ b/Tzkt.Data/TzktContext.cs @@ -127,6 +127,10 @@ public class TzktContext : DbContext public DbSet InboxMessages { get; set; } #endregion + #region dal + public DbSet DalCommitmentStatus { get; set; } + #endregion + #region plugins public DbSet Quotes { get; set; } public DbSet Domains { get; set; } From f86f0d765fd4fb090fa4fccf9da16e81b0617ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Mon, 5 Aug 2024 10:52:58 +0200 Subject: [PATCH 2/6] [dal-commitment] index DAL commitments on applied publishment --- .../Commits/Operations/DalPublishCommitmentCommit.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/Operations/DalPublishCommitmentCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/Operations/DalPublishCommitmentCommit.cs index ff603aa7..9c695535 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/Operations/DalPublishCommitmentCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto19/Commits/Operations/DalPublishCommitmentCommit.cs @@ -74,7 +74,11 @@ public async Task Apply(Block block, JsonElement op, JsonElement content) #region apply result if (operation.Status == OperationStatus.Applied) { - // nothing to do + var commitmentStatus = new DalCommitmentStatus + { + PublishmentId = operation.Id, + }; + Db.DalCommitmentStatus.Add(commitmentStatus); } #endregion @@ -93,7 +97,7 @@ public async Task Revert(Block block, DalPublishCommitmentOperation operation) #region revert result if (operation.Status == OperationStatus.Applied) { - // nothing to do + Db.DalCommitmentStatus.Remove(operation.DalCommitmentStatus); } #endregion From 474b92c842adf59596a661415012da687c837657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Mon, 5 Aug 2024 14:46:22 +0200 Subject: [PATCH 3/6] [api] add a parameter template for DAL commitment hash --- .../ModelBindingContextExtension.cs | 61 +++++++++++++++ .../Binders/DalCommitmentHashBinder.cs | 44 +++++++++++ .../Parameters/DalCommitmentHashParameter.cs | 74 +++++++++++++++++++ Tzkt.Api/Utils/SqlBuilder.cs | 19 +++++ 4 files changed, 198 insertions(+) create mode 100644 Tzkt.Api/Parameters/Binders/DalCommitmentHashBinder.cs create mode 100644 Tzkt.Api/Parameters/DalCommitmentHashParameter.cs diff --git a/Tzkt.Api/Extensions/ModelBindingContextExtension.cs b/Tzkt.Api/Extensions/ModelBindingContextExtension.cs index a61c03ee..e225f754 100644 --- a/Tzkt.Api/Extensions/ModelBindingContextExtension.cs +++ b/Tzkt.Api/Extensions/ModelBindingContextExtension.cs @@ -878,6 +878,67 @@ public static bool TryGetSrc1HashList(this ModelBindingContext bindingContext, s return true; } + public static bool TryGetDalCommitmentHash(this ModelBindingContext bindingContext, string name, ref bool hasValue, out string result) + { + result = null; + var valueObject = bindingContext.ValueProvider.GetValue(name); + + if (valueObject != ValueProviderResult.None) + { + bindingContext.ModelState.SetModelValue(name, valueObject); + if (!string.IsNullOrEmpty(valueObject.FirstValue)) + { + if (!Regex.IsMatch(valueObject.FirstValue, "^sh[0-9A-Za-z]{72}$")) + { + bindingContext.ModelState.TryAddModelError(name, "Invalid DAL commitment hash."); + return false; + } + + hasValue = true; + result = valueObject.FirstValue; + } + } + + return true; + } + + public static bool TryGetDalCommitmentHashList(this ModelBindingContext bindingContext, string name, ref bool hasValue, out List result) + { + result = null; + var valueObject = bindingContext.ValueProvider.GetValue(name); + + if (valueObject != ValueProviderResult.None) + { + bindingContext.ModelState.SetModelValue(name, valueObject); + if (!string.IsNullOrEmpty(valueObject.FirstValue)) + { + var rawValues = valueObject.FirstValue.Split(',', StringSplitOptions.RemoveEmptyEntries); + + if (rawValues.Length == 0) + { + bindingContext.ModelState.TryAddModelError(name, "List should contain at least one item."); + return false; + } + + hasValue = true; + result = new List(rawValues.Length); + + foreach (var rawValue in rawValues) + { + if (!Regex.IsMatch(rawValue, "^sh[0-9A-Za-z]{72}$")) + { + bindingContext.ModelState.TryAddModelError(name, "List contains invalid DAL commitment hash."); + return false; + } + + result.Add(rawValue); + } + } + } + + return true; + } + public static bool TryGetContractKind(this ModelBindingContext bindingContext, string name, ref bool hasValue, out int? result) { result = null; diff --git a/Tzkt.Api/Parameters/Binders/DalCommitmentHashBinder.cs b/Tzkt.Api/Parameters/Binders/DalCommitmentHashBinder.cs new file mode 100644 index 00000000..f65763a7 --- /dev/null +++ b/Tzkt.Api/Parameters/Binders/DalCommitmentHashBinder.cs @@ -0,0 +1,44 @@ +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Tzkt.Api +{ + public class DalCommitmentHashBinder : IModelBinder + { + public Task BindModelAsync(ModelBindingContext bindingContext) + { + var model = bindingContext.ModelName; + var hasValue = false; + + if (!bindingContext.TryGetDalCommitmentHash($"{model}", ref hasValue, out var value)) + return Task.CompletedTask; + + if (!bindingContext.TryGetDalCommitmentHash($"{model}.eq", ref hasValue, out var eq)) + return Task.CompletedTask; + + if (!bindingContext.TryGetDalCommitmentHash($"{model}.ne", ref hasValue, out var ne)) + return Task.CompletedTask; + + if (!bindingContext.TryGetDalCommitmentHashList($"{model}.in", ref hasValue, out var @in)) + return Task.CompletedTask; + + if (!bindingContext.TryGetDalCommitmentHashList($"{model}.ni", ref hasValue, out var ni)) + return Task.CompletedTask; + + if (!hasValue) + { + bindingContext.Result = ModelBindingResult.Success(null); + return Task.CompletedTask; + } + + bindingContext.Result = ModelBindingResult.Success(new DalCommitmentHashParameter + { + Eq = value ?? eq, + Ne = ne, + In = @in, + Ni = ni + }); + + return Task.CompletedTask; + } + } +} diff --git a/Tzkt.Api/Parameters/DalCommitmentHashParameter.cs b/Tzkt.Api/Parameters/DalCommitmentHashParameter.cs new file mode 100644 index 00000000..51418089 --- /dev/null +++ b/Tzkt.Api/Parameters/DalCommitmentHashParameter.cs @@ -0,0 +1,74 @@ +using System.Text; +using Microsoft.AspNetCore.Mvc; +using NJsonSchema.Annotations; + +namespace Tzkt.Api +{ + [ModelBinder(BinderType = typeof(DalCommitmentHashBinder))] + [JsonSchemaExtensionData("x-tzkt-extension", "query-parameter")] + public class DalCommitmentHashParameter : INormalizable + { + /// + /// **Equal** filter mode (`.eq` suffix can be omitted, i.e. `?param=...` is the same as `?param.eq=...`). \ + /// Specify an DAL commitment hash to get items where the specified field is equal to the specified value. + /// + /// Example: `?hash=sh...`. + /// + public string Eq { get; set; } + + /// + /// **Not equal** filter mode. \ + /// Specify an DAL commitment hash to get items where the specified field is not equal to the specified value. + /// + /// Example: `?hash.ne=sh...`. + /// + public string Ne { get; set; } + + /// + /// **In list** (any of) filter mode. \ + /// Specify a comma-separated list of DAL commitment hashes to get items where the specified field is equal to one of the specified values. + /// + /// Example: `?hash.in=hash1,hash2,hash3`. + /// + public List In { get; set; } + + /// + /// **Not in list** (none of) filter mode. \ + /// Specify a comma-separated list of DAL commitment hashes to get items where the specified field is not equal to all the specified values. + /// + /// Example: `?hash.ni=hash1,hash2,hash3`. + /// + public List Ni { get; set; } + + #region operators + public static implicit operator DalCommitmentHashParameter(string value) => new() { Eq = value }; + #endregion + + public string Normalize(string name) + { + var sb = new StringBuilder(); + + if (Eq != null) + { + sb.Append($"{name}.eq={Eq}&"); + } + + if (Ne != null) + { + sb.Append($"{name}.ne={Ne}&"); + } + + if (In?.Count > 0) + { + sb.Append($"{name}.in={string.Join(",", In.OrderBy(x => x))}&"); + } + + if (Ni?.Count > 0) + { + sb.Append($"{name}.ni={string.Join(",", Ni.OrderBy(x => x))}&"); + } + + return sb.ToString(); + } + } +} diff --git a/Tzkt.Api/Utils/SqlBuilder.cs b/Tzkt.Api/Utils/SqlBuilder.cs index 4400723c..7ec2be7c 100644 --- a/Tzkt.Api/Utils/SqlBuilder.cs +++ b/Tzkt.Api/Utils/SqlBuilder.cs @@ -618,6 +618,25 @@ public SqlBuilder FilterA(string column, Src1HashParameter hash) return this; } + public SqlBuilder FilterA(string column, DalCommitmentHashParameter hash) + { + if (hash == null) return this; + + if (hash.Eq != null) + AppendFilter($"{column} = {Param(hash.Eq)}::character(74)"); + + if (hash.Ne != null) + AppendFilter($"{column} != {Param(hash.Ne)}::character(74)"); + + if (hash.In != null) + AppendFilter($"{column} = ANY ({Param(hash.In)})"); + + if (hash.Ni != null && hash.Ni.Count > 0) + AppendFilter($"NOT ({column} = ANY ({Param(hash.Ni)}))"); + + return this; + } + public SqlBuilder Filter(string column, ProtocolParameter protocol) { if (protocol == null) return this; From 6c95f992258f986f2ed28833b7626456a7436f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Mon, 5 Aug 2024 14:47:36 +0200 Subject: [PATCH 4/6] [api] add an endpoint to count DAL commitments Authorize to filter by: - hash - level - slot-index - publisher --- Tzkt.Api/Controllers/DalController.cs | 41 ++++++++++++++++++++++++ Tzkt.Api/Program.cs | 1 + Tzkt.Api/Repositories/DalRepository.cs | 43 ++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 Tzkt.Api/Controllers/DalController.cs create mode 100644 Tzkt.Api/Repositories/DalRepository.cs diff --git a/Tzkt.Api/Controllers/DalController.cs b/Tzkt.Api/Controllers/DalController.cs new file mode 100644 index 00000000..57d301f8 --- /dev/null +++ b/Tzkt.Api/Controllers/DalController.cs @@ -0,0 +1,41 @@ +using Microsoft.AspNetCore.Mvc; +using Tzkt.Api.Models; +using Tzkt.Api.Repositories; + +namespace Tzkt.Api.Controllers +{ + [ApiController] + [Route("v1/dal")] + public class DalController : ControllerBase + { + private readonly DalRepository Dal; + + public DalController(DalRepository dal) + { + Dal = dal; + } + + #region commiments + /// + /// Get DAL commitments count + /// + /// + /// Returns total number of DAL commitments published. + /// + /// Filters by DAL commitment hash + /// Filters by level + /// Filters by slot-index + /// Filters by DAL commitment publisher + /// + [HttpGet("commitments/count")] + public async Task GetDalCommitmentsCount( + DalCommitmentHashParameter hash, + Int32Parameter level, + Int32Parameter slotIndex, + AccountParameter publisher) + { + return await Dal.GetCommitmentsCount(hash, level, slotIndex, publisher); + } + #endregion + } +} diff --git a/Tzkt.Api/Program.cs b/Tzkt.Api/Program.cs index edfc7888..cf24cfe0 100644 --- a/Tzkt.Api/Program.cs +++ b/Tzkt.Api/Program.cs @@ -80,6 +80,7 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddAuthService(builder.Configuration); builder.Services.AddSingleton(); diff --git a/Tzkt.Api/Repositories/DalRepository.cs b/Tzkt.Api/Repositories/DalRepository.cs new file mode 100644 index 00000000..a9ed314f --- /dev/null +++ b/Tzkt.Api/Repositories/DalRepository.cs @@ -0,0 +1,43 @@ +using Dapper; +using Npgsql; +using Tzkt.Api.Services.Cache; + +namespace Tzkt.Api.Repositories +{ + public class DalRepository + { + readonly NpgsqlDataSource DataSource; + readonly AccountsCache Accounts; + readonly ProtocolsCache Protocols; + readonly QuotesCache Quotes; + + public DalRepository(NpgsqlDataSource dataSource, AccountsCache accounts, ProtocolsCache protocols, QuotesCache quotes) + { + DataSource = dataSource; + Accounts = accounts; + Protocols = protocols; + Quotes = quotes; + } + + #region commiments + public async Task GetCommitmentsCount( + DalCommitmentHashParameter hash, + Int32Parameter level, + Int32Parameter slotIndex, + AccountParameter publisher) + { + var sql = new SqlBuilder($""" + SELECT COUNT(*) FROM "DalCommitmentStatus" AS dc + INNER JOIN "DalPublishCommitmentOps" AS op ON dc."PublishmentId" = op."Id" + """) + .FilterA(@"op.""Commitment""", hash) + .FilterA(@"op.""Level""", level) + .FilterA(@"op.""Slot""", slotIndex) + .FilterA(@"op.""SenderId""", publisher); + + await using var db = await DataSource.OpenConnectionAsync(); + return await db.QueryFirstAsync(sql.Query, sql.Params); + } + #endregion + } +} From 67da31c0b5ed9d0b3fd586fe95bfa014fd1208c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Tue, 6 Aug 2024 09:10:12 +0200 Subject: [PATCH 5/6] [api] add an endpoint to get DAL commitment information Authorize to select fields: - hash - level - slotIndex - publisher Authorize to filter by: - hash - level - slotIndex - publisher Authorize to sort by: - level - slotIndex --- Tzkt.Api/Controllers/DalController.cs | 57 ++++++++ Tzkt.Api/Models/Dal/DalCommitment.cs | 25 ++++ Tzkt.Api/Repositories/DalRepository.cs | 178 +++++++++++++++++++++++++ 3 files changed, 260 insertions(+) create mode 100644 Tzkt.Api/Models/Dal/DalCommitment.cs diff --git a/Tzkt.Api/Controllers/DalController.cs b/Tzkt.Api/Controllers/DalController.cs index 57d301f8..ff0340ed 100644 --- a/Tzkt.Api/Controllers/DalController.cs +++ b/Tzkt.Api/Controllers/DalController.cs @@ -1,3 +1,4 @@ +using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Mvc; using Tzkt.Api.Models; using Tzkt.Api.Repositories; @@ -36,6 +37,62 @@ public async Task GetDalCommitmentsCount( { return await Dal.GetCommitmentsCount(hash, level, slotIndex, publisher); } + + /// + /// Get DAL commitments information + /// + /// + /// Returns information of the DAL commitments published. + /// + /// Filters by DAL commitment hash + /// Filters by level + /// Filters by slot-index + /// Filters by DAL commitment publisher + /// Specify comma-separated list of fields to include into response or leave it undefined to return full object. If you select single field, response will be an array of values in both `.fields` and `.values` modes. + /// Sorts DAL commitments by specified field. Supported fields: `level` (default), `slotIndex`. + /// Specifies which or how many items should be skipped + /// Maximum number of items to return + /// + [HttpGet("commitments")] + public async Task>> GetDalCommitments( + DalCommitmentHashParameter hash, + Int32Parameter level, + Int32Parameter slotIndex, + AccountParameter publisher, + SelectParameter select, + SortParameter sort, + OffsetParameter offset, + [Range(0, 10000)] int limit = 100) + { + #region validate + if (sort != null && !sort.Validate("level", "slotIndex")) + return new BadRequest($"{nameof(sort)}", "Sorting by the specified field is not allowed."); + #endregion + + if (select == null) + return Ok(await Dal.GetCommitments(hash, level, slotIndex, publisher, sort, offset, limit)); + + if (select.Values != null) + { + if (select.Values.Length == 1) + return Ok(await Dal.GetCommitments(hash, level, slotIndex, publisher, sort, offset, limit, select.Values[0])); + else + return Ok(await Dal.GetCommitments(hash, level, slotIndex, publisher, sort, offset, limit, select.Values)); + } + else + { + if (select.Fields.Length == 1) + return Ok(await Dal.GetCommitments(hash, level, slotIndex, publisher, sort, offset, limit, select.Fields[0])); + else + { + return Ok(new SelectionResponse + { + Cols = select.Fields, + Rows = await Dal.GetCommitments(hash, level, slotIndex, publisher, sort, offset, limit, select.Fields) + }); + } + } + } #endregion } } diff --git a/Tzkt.Api/Models/Dal/DalCommitment.cs b/Tzkt.Api/Models/Dal/DalCommitment.cs new file mode 100644 index 00000000..fe224a58 --- /dev/null +++ b/Tzkt.Api/Models/Dal/DalCommitment.cs @@ -0,0 +1,25 @@ +namespace Tzkt.Api.Models +{ + public class DalCommitment + { + /// + /// Level at which the commitment has been published. + /// + public int Level { get; set; } + + /// + /// Slot index associated with the commitment. + /// + public int SlotIndex { get; set; } + + /// + /// Hash of the commitment. + /// + public string Hash { get; set; } + + /// + /// Information about the account who has published the commitment. + /// + public Alias Publisher { get; set; } + } +} diff --git a/Tzkt.Api/Repositories/DalRepository.cs b/Tzkt.Api/Repositories/DalRepository.cs index a9ed314f..5ffe7c22 100644 --- a/Tzkt.Api/Repositories/DalRepository.cs +++ b/Tzkt.Api/Repositories/DalRepository.cs @@ -1,5 +1,6 @@ using Dapper; using Npgsql; +using Tzkt.Api.Models; using Tzkt.Api.Services.Cache; namespace Tzkt.Api.Repositories @@ -38,6 +39,183 @@ SELECT COUNT(*) FROM "DalCommitmentStatus" AS dc await using var db = await DataSource.OpenConnectionAsync(); return await db.QueryFirstAsync(sql.Query, sql.Params); } + + public async Task> GetCommitments( + DalCommitmentHashParameter hash, + Int32Parameter level, + Int32Parameter slotIndex, + AccountParameter publisher, + SortParameter sort, + OffsetParameter offset, + int limit) + { + var sql = new SqlBuilder($""" + SELECT op.* + FROM "DalCommitmentStatus" AS dc + INNER JOIN "DalPublishCommitmentOps" AS op ON dc."PublishmentId" = op."Id" + """) + .FilterA(@"op.""Commitment""", hash) + .FilterA(@"op.""Level""", level) + .FilterA(@"op.""Slot""", slotIndex) + .FilterA(@"op.""SenderId""", publisher) + .Take(new Pagination { sort = sort, offset = offset, limit = limit }, x => x switch + { + "slotIndex" => (@"op.""Slot""", @"op.""Slot"""), + "level" or _ => (@"op.""Level""", @"op.""Level""") + }, @"op.""Level"""); + + await using var db = await DataSource.OpenConnectionAsync(); + var rows = await db.QueryAsync(sql.Query, sql.Params); + + return rows.Select(row => new DalCommitment + { + Level = row.Level, + SlotIndex = row.Slot, + Hash = row.Commitment, + Publisher = Accounts.GetAlias(row.SenderId) + }); + } + + public async Task GetCommitments( + DalCommitmentHashParameter hash, + Int32Parameter level, + Int32Parameter slotIndex, + AccountParameter publisher, + SortParameter sort, + OffsetParameter offset, + int limit, + string[] fields) + { + var columns = new HashSet(fields.Length); + + foreach (var field in fields) + { + switch (field) + { + case "level": columns.Add(@"op.""Level"""); break; + case "slotIndex": columns.Add(@"op.""Slot"""); break; + case "hash": columns.Add(@"op.""Commitment"""); break; + case "publisher": columns.Add(@"op.""SenderId"""); break; + } + } + + if (columns.Count == 0) + return Array.Empty(); + + var sql = new SqlBuilder($""" + SELECT {string.Join(',', columns)} + FROM "DalCommitmentStatus" AS dc + INNER JOIN "DalPublishCommitmentOps" AS op ON dc."PublishmentId" = op."Id" + """) + .FilterA(@"op.""Commitment""", hash) + .FilterA(@"op.""Level""", level) + .FilterA(@"op.""Slot""", slotIndex) + .FilterA(@"op.""SenderId""", publisher) + .Take(new Pagination { sort = sort, offset = offset, limit = limit }, x => x switch + { + "slotIndex" => (@"op.""Slot""", @"op.""Slot"""), + "level" or _ => (@"op.""Level""", @"op.""Level""") + }, @"op.""Level"""); + + await using var db = await DataSource.OpenConnectionAsync(); + var rows = await db.QueryAsync(sql.Query, sql.Params); + + var result = new object[rows.Count()][]; + for (int i = 0; i < result.Length; i++) + result[i] = new object[fields.Length]; + + for (int i = 0, j = 0; i < fields.Length; j = 0, i++) + { + switch (fields[i]) + { + case "level": + foreach (var row in rows) + result[j++][i] = row.Level; + break; + case "slotIndex": + foreach (var row in rows) + result[j++][i] = row.Slot; + break; + case "hash": + foreach (var row in rows) + result[j++][i] = row.Commitment; + break; + case "publisher": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.SenderId); + break; + } + } + + return result; + } + + public async Task GetCommitments( + DalCommitmentHashParameter hash, + Int32Parameter level, + Int32Parameter slotIndex, + AccountParameter publisher, + SortParameter sort, + OffsetParameter offset, + int limit, + string field) + { + var columns = new HashSet(1); + + switch (field) + { + case "level": columns.Add(@"op.""Level"""); break; + case "slotIndex": columns.Add(@"op.""Slot"""); break; + case "hash": columns.Add(@"op.""Commitment"""); break; + case "publisher": columns.Add(@"op.""SenderId"""); break; + } + + if (columns.Count == 0) + return Array.Empty(); + + var sql = new SqlBuilder($""" + SELECT {string.Join(',', columns)} + FROM "DalCommitmentStatus" AS dc + INNER JOIN "DalPublishCommitmentOps" AS op ON dc."PublishmentId" = op."Id" + """) + .FilterA(@"op.""Commitment""", hash) + .FilterA(@"op.""Level""", level) + .FilterA(@"op.""Slot""", slotIndex) + .FilterA(@"op.""SenderId""", publisher) + .Take(new Pagination { sort = sort, offset = offset, limit = limit }, x => x switch + { + "slotIndex" => (@"op.""Slot""", @"op.""Slot"""), + "level" or _ => (@"op.""Level""", @"op.""Level""") + }, @"op.""Level"""); + + await using var db = await DataSource.OpenConnectionAsync(); + var rows = await db.QueryAsync(sql.Query, sql.Params); + + var result = new object[rows.Count()]; + var j = 0; + + switch (field) + { + case "level": + foreach (var row in rows) + result[j++] = row.Level; + break; + case "slotIndex": + foreach (var row in rows) + result[j++] = row.Slot; + break; + case "hash": + foreach (var row in rows) + result[j++] = row.Commitment; + break; + case "publisher": + foreach (var row in rows) + result[j++] = Accounts.GetAlias(row.SenderId); + break; + } + + return result; + } #endregion } } From 3b7082fdb7ef3bdae91dfb99fb63a741b182ac28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Tue, 6 Aug 2024 10:38:28 +0200 Subject: [PATCH 6/6] [api] add an endpoint to get DAL commitment information by hash Authorize to select fields: - hash - level - slotIndex - publisher Authorize to filter by: - level - slotIndex - publisher Authorize to sort by: - level - slotIndex --- Tzkt.Api/Controllers/DalController.cs | 28 +++++++++++++++++++ .../Validation/DalCommitmentHashAttribute.cs | 14 ++++++++++ 2 files changed, 42 insertions(+) create mode 100644 Tzkt.Api/Validation/DalCommitmentHashAttribute.cs diff --git a/Tzkt.Api/Controllers/DalController.cs b/Tzkt.Api/Controllers/DalController.cs index ff0340ed..d2988025 100644 --- a/Tzkt.Api/Controllers/DalController.cs +++ b/Tzkt.Api/Controllers/DalController.cs @@ -93,6 +93,34 @@ public async Task>> GetDalCommitments( } } } + + /// + /// Get DAL commitments information by hash + /// + /// + /// Returns information of the DAL commitments published with the specified hash. + /// + /// DAL commitment hash + /// Filters by level + /// Filters by slot-index + /// Filters by DAL commitment publisher + /// Specify comma-separated list of fields to include into response or leave it undefined to return full object. If you select single field, response will be an array of values in both `.fields` and `.values` modes. + /// Sorts DAL commitments by specified field. Supported fields: `level` (default), `slotIndex`. + /// Specifies which or how many items should be skipped + /// Maximum number of items to return + /// + [HttpGet("commitments/{hash}")] + public async Task>> GetDalCommitmentsByHash( + [Required][DalCommitmentHash] string hash, + Int32Parameter level, + Int32Parameter slotIndex, + AccountParameter publisher, + SelectParameter select, + SortParameter sort, + OffsetParameter offset, + [Range(0, 10000)] int limit = 100) + => + await GetDalCommitments(new DalCommitmentHashParameter { Eq = hash }, level, slotIndex, publisher, select, sort, offset, limit); #endregion } } diff --git a/Tzkt.Api/Validation/DalCommitmentHashAttribute.cs b/Tzkt.Api/Validation/DalCommitmentHashAttribute.cs new file mode 100644 index 00000000..4cc2cb87 --- /dev/null +++ b/Tzkt.Api/Validation/DalCommitmentHashAttribute.cs @@ -0,0 +1,14 @@ +using System.Text.RegularExpressions; + +namespace System.ComponentModel.DataAnnotations +{ + public sealed class DalCommitmentHashAttribute : ValidationAttribute + { + protected override ValidationResult IsValid(object value, ValidationContext validationContext) + { + return value != null && !Regex.IsMatch((string)value, "^sh[0-9A-Za-z]{72}$") + ? new ValidationResult("Invalid DAL commitment hash.") + : ValidationResult.Success; + } + } +}