Skip to content

Commit

Permalink
Added missing index on validator_cumulative_emission_history
Browse files Browse the repository at this point in the history
  • Loading branch information
krzlabrdx committed Aug 27, 2024
1 parent ef43894 commit 2234e8a
Show file tree
Hide file tree
Showing 7 changed files with 3,045 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.7.1
Release built: _not released yet_

### Database changes
- Added missing index on `validator_cumulative_emission_history`

## 1.7.0
Release built: _not released yet_

Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<PropertyGroup>
<VersionPrefix>1.7.0</VersionPrefix>
<VersionPrefix>1.7.1</VersionPrefix>
<VersionSuffix>develop</VersionSuffix>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,10 @@ private static void HookupHistory(ModelBuilder modelBuilder)
.Entity<ValidatorCumulativeEmissionHistory>()
.HasIndex(e => new { e.ValidatorEntityId, e.EpochNumber });

modelBuilder
.Entity<ValidatorCumulativeEmissionHistory>()
.HasIndex(e => new { e.ValidatorEntityId, e.FromStateVersion });

modelBuilder
.Entity<UnverifiedStandardMetadataAggregateHistory>()
.HasIndex(e => new { e.EntityId, e.FromStateVersion });
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
*
* Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
*
* radixfoundation.org/licenses/LICENSE-v1
*
* The Licensor hereby grants permission for the Canonical version of the Work to be
* published, distributed and used under or by reference to the Licensor’s trademark
* Radix ® and use of any unregistered trade names, logos or get-up.
*
* The Licensor provides the Work (and each Contributor provides its Contributions) on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
* including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
*
* Whilst the Work is capable of being deployed, used and adopted (instantiated) to create
* a distributed ledger it is your responsibility to test and validate the code, together
* with all logic and performance of that code under all foreseeable scenarios.
*
* The Licensor does not make or purport to make and hereby excludes liability for all
* and any representation, warranty or undertaking in any form whatsoever, whether express
* or implied, to any entity or person, including any representation, warranty or
* undertaking, as to the functionality security use, value or other characteristics of
* any distributed ledger nor in respect the functioning or value of any tokens which may
* be created stored or transferred using the Work. The Licensor does not warrant that the
* Work or any use of the Work complies with any law or regulation in any territory where
* it may be implemented or used or that it will be appropriate for any specific purpose.
*
* Neither the licensor nor any current or former employees, officers, directors, partners,
* trustees, representatives, agents, advisors, contractors, or volunteers of the Licensor
* shall be liable for any direct or indirect, special, incidental, consequential or other
* losses of any kind, in tort, contract or otherwise (including but not limited to loss
* of revenue, income or profits, or loss of use or data, or loss of reputation, or loss
* of any economic or other opportunity of whatsoever nature or howsoever arising), arising
* out of or in connection with (without limitation of any use, misuse, of any ledger system
* or use made or its functionality or any performance or operation of any code or protocol
* caused by bugs or programming or logic errors or otherwise);
*
* A. any offer, purchase, holding, use, sale, exchange or transmission of any
* cryptographic keys, tokens or assets created, exchanged, stored or arising from any
* interaction with the Work;
*
* B. any failure in a transmission or loss of any token or assets keys or other digital
* artefacts due to errors in transmission;
*
* C. bugs, hacks, logic errors or faults in the Work or any communication;
*
* D. system software or apparatus including but not limited to losses caused by errors
* in holding or transmitting tokens by any third-party;
*
* E. breaches or failure of security including hacker attacks, loss or disclosure of
* password, loss of private key, unauthorised use or misuse of such passwords or keys;
*
* F. any losses including loss of anticipated savings or other benefits resulting from
* use of the Work or any changes to the Work (however implemented).
*
* You are solely responsible for; testing, validating and evaluation of all operation
* logic, functionality, security and appropriateness of using the Work for any commercial
* or non-commercial purpose and for any reproduction or redistribution by You of the
* Work. You assume all risks associated with Your use of the Work and the exercise of
* permissions under this License.
*/

using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace RadixDlt.NetworkGateway.PostgresIntegration.Migrations
{
/// <inheritdoc />
public partial class AddValidatorCumulativeEmissionHistoryIdx : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_validator_cumulative_emission_history_validator_entity_id_f~",
table: "validator_cumulative_emission_history",
columns: new[] { "validator_entity_id", "from_state_version" });
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_validator_cumulative_emission_history_validator_entity_id_f~",
table: "validator_cumulative_emission_history");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1282,3 +1282,22 @@ BEGIN
END $EF$;
COMMIT;

START TRANSACTION;


DO $EF$
BEGIN
IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240827101440_AddValidatorCumulativeEmissionHistoryIdx') THEN
CREATE INDEX "IX_validator_cumulative_emission_history_validator_entity_id_f~" ON validator_cumulative_emission_history (validator_entity_id, from_state_version);
END IF;
END $EF$;

DO $EF$
BEGIN
IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240827101440_AddValidatorCumulativeEmissionHistoryIdx') THEN
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20240827101440_AddValidatorCumulativeEmissionHistoryIdx', '8.0.2');
END IF;
END $EF$;
COMMIT;

Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("ValidatorEntityId", "EpochNumber");

b.HasIndex("ValidatorEntityId", "FromStateVersion");

b.ToTable("validator_cumulative_emission_history");
});

Expand Down

0 comments on commit 2234e8a

Please sign in to comment.