From 9b73e33b13a914b9bf1a02c36949e9b68d3a950a Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 8 Jun 2026 01:32:59 -0400 Subject: [PATCH] Add current round best share index migration --- ...CurrentRoundBestShareIndex1780897600000.ts | 22 +++++++++++++++++++ src/database.config.ts | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 src/ORM/_migrations/CurrentRoundBestShareIndex1780897600000.ts diff --git a/src/ORM/_migrations/CurrentRoundBestShareIndex1780897600000.ts b/src/ORM/_migrations/CurrentRoundBestShareIndex1780897600000.ts new file mode 100644 index 0000000..2514083 --- /dev/null +++ b/src/ORM/_migrations/CurrentRoundBestShareIndex1780897600000.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class CurrentRoundBestShareIndex1780897600000 implements MigrationInterface { + public name = 'CurrentRoundBestShareIndex1780897600000'; + public transaction = false; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP INDEX IF EXISTS "IDX_address_settings_best_difficulty"`); + await queryRunner.query(` + CREATE INDEX IF NOT EXISTS "IDX_accepted_share_round_best" + ON "accepted_share_entity" ("submissionDifficulty" DESC, "acceptedAt" DESC, "blockHeight") + `); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP INDEX IF EXISTS "IDX_accepted_share_round_best"`); + await queryRunner.query(` + CREATE INDEX IF NOT EXISTS "IDX_address_settings_best_difficulty" + ON "address_settings_entity" ("bestDifficulty" DESC) + `); + } +} diff --git a/src/database.config.ts b/src/database.config.ts index 5a0e6e6..92b0771 100644 --- a/src/database.config.ts +++ b/src/database.config.ts @@ -7,6 +7,7 @@ import { TimescaleOperationalHardening1780861200000 } from './ORM/_migrations/Ti import { AcceptedShareIndex1780862400000 } from './ORM/_migrations/AcceptedShareIndex1780862400000'; import { AcceptedShareRollupIndexes1780865400000 } from './ORM/_migrations/AcceptedShareRollupIndexes1780865400000'; import { PoolAccountingDashboardIndexes1780867200000 } from './ORM/_migrations/PoolAccountingDashboardIndexes1780867200000'; +import { CurrentRoundBestShareIndex1780897600000 } from './ORM/_migrations/CurrentRoundBestShareIndex1780897600000'; import { UserAgentReportView } from './ORM/_views/user-agent-report/user-agent-report.view'; import { AcceptedShareEntity } from './ORM/accepted-share/accepted-share.entity'; import { AddressSettingsEntity } from './ORM/address-settings/address-settings.entity'; @@ -32,6 +33,7 @@ export const databaseMigrations = [ AcceptedShareIndex1780862400000, AcceptedShareRollupIndexes1780865400000, PoolAccountingDashboardIndexes1780867200000, + CurrentRoundBestShareIndex1780897600000, ]; export function createDatabaseOptions(env: NodeJS.ProcessEnv): TypeOrmModuleOptions & DataSourceOptions {