From 6dbf123f9b42e9828816021136b18a6a742376a9 Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Tue, 6 Jan 2026 14:35:21 -0600 Subject: [PATCH] chore: consolidate migration files --- migrations/1670265062169_tokens.ts | 3 ++ migrations/1670266371036_jobs.ts | 13 +++++++++ .../1721103820876_update-notifications.ts | 11 +++++++ .../1724185248660_invalid-job-reasons.ts | 12 -------- migrations/1725039927416_job-retry-after.ts | 12 -------- migrations/1744169665745_optimize-indexes.ts | 29 ------------------- migrations/1744225682001_ft-lower-index.ts | 20 ------------- 7 files changed, 27 insertions(+), 73 deletions(-) delete mode 100644 migrations/1724185248660_invalid-job-reasons.ts delete mode 100644 migrations/1725039927416_job-retry-after.ts delete mode 100644 migrations/1744169665745_optimize-indexes.ts delete mode 100644 migrations/1744225682001_ft-lower-index.ts diff --git a/migrations/1670265062169_tokens.ts b/migrations/1670265062169_tokens.ts index abbe2079..02c70db0 100644 --- a/migrations/1670265062169_tokens.ts +++ b/migrations/1670265062169_tokens.ts @@ -74,4 +74,7 @@ export function up(pgm: MigrationBuilder): void { pgm.createIndex('tokens', 'COALESCE(updated_at, created_at)'); pgm.createIndex('tokens', ['name']); pgm.createIndex('tokens', ['symbol']); + pgm.createIndex('tokens', ['type', 'LOWER(name)'], { where: "type = 'ft'" }); + pgm.createIndex('tokens', ['type', 'LOWER(symbol)'], { where: "type = 'ft'" }); + pgm.createIndex('tokens', ['type']); } diff --git a/migrations/1670266371036_jobs.ts b/migrations/1670266371036_jobs.ts index ae0f5cce..b1d3094e 100644 --- a/migrations/1670266371036_jobs.ts +++ b/migrations/1670266371036_jobs.ts @@ -36,6 +36,12 @@ export function up(pgm: MigrationBuilder): void { updated_at: { type: 'timestamptz', }, + invalid_reason: { + type: 'int', + }, + retry_after: { + type: 'timestamptz', + }, }); pgm.createConstraint( 'jobs', @@ -45,4 +51,11 @@ export function up(pgm: MigrationBuilder): void { pgm.createIndex('jobs', ['status'], { where: "status = 'pending'" }); pgm.createIndex('jobs', ['token_id'], { where: 'smart_contract_id IS NULL', unique: true }); pgm.createIndex('jobs', ['smart_contract_id'], { where: 'token_id IS NULL', unique: true }); + + pgm.createIndex('jobs', ['token_id']); + pgm.createIndex('jobs', ['smart_contract_id']); + pgm.createIndex('jobs', ['status'], { name: 'jobs_status_all_index' }); + pgm.createIndex('jobs', ['status', { name: 'updated_at', sort: 'ASC' }], { + where: "status = 'queued'", + }); } diff --git a/migrations/1721103820876_update-notifications.ts b/migrations/1721103820876_update-notifications.ts index d75c2291..c680c77d 100644 --- a/migrations/1721103820876_update-notifications.ts +++ b/migrations/1721103820876_update-notifications.ts @@ -43,4 +43,15 @@ export function up(pgm: MigrationBuilder): void { pgm.createIndex('update_notifications', ['token_id', 'block_height', 'tx_index', 'event_index'], { unique: true, }); + pgm.createIndex( + 'update_notifications', + [ + 'update_mode', + 'token_id', + { name: 'block_height', sort: 'DESC' }, + { name: 'tx_index', sort: 'DESC' }, + { name: 'event_index', sort: 'DESC' }, + ], + { where: "update_mode = 'dynamic'" } + ); } diff --git a/migrations/1724185248660_invalid-job-reasons.ts b/migrations/1724185248660_invalid-job-reasons.ts deleted file mode 100644 index 1643f60e..00000000 --- a/migrations/1724185248660_invalid-job-reasons.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate'; - -export const shorthands: ColumnDefinitions | undefined = undefined; - -export function up(pgm: MigrationBuilder): void { - pgm.addColumn('jobs', { - invalid_reason: { - type: 'int', - }, - }); -} diff --git a/migrations/1725039927416_job-retry-after.ts b/migrations/1725039927416_job-retry-after.ts deleted file mode 100644 index 3adefafd..00000000 --- a/migrations/1725039927416_job-retry-after.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate'; - -export const shorthands: ColumnDefinitions | undefined = undefined; - -export function up(pgm: MigrationBuilder): void { - pgm.addColumn('jobs', { - retry_after: { - type: 'timestamptz', - }, - }); -} diff --git a/migrations/1744169665745_optimize-indexes.ts b/migrations/1744169665745_optimize-indexes.ts deleted file mode 100644 index e9302943..00000000 --- a/migrations/1744169665745_optimize-indexes.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate'; - -export const shorthands: ColumnDefinitions | undefined = undefined; - -export function up(pgm: MigrationBuilder): void { - pgm.createIndex('jobs', ['token_id']); - pgm.createIndex('jobs', ['smart_contract_id']); - pgm.createIndex('jobs', ['status'], { name: 'jobs_status_all_index' }); - pgm.createIndex('jobs', ['status', { name: 'updated_at', sort: 'ASC' }], { - where: "status = 'queued'", - }); - - pgm.createIndex('tokens', ['type', 'name'], { where: "type = 'ft'" }); - pgm.createIndex('tokens', ['type', 'symbol'], { where: "type = 'ft'" }); - pgm.createIndex('tokens', ['type']); - - pgm.createIndex( - 'update_notifications', - [ - 'update_mode', - 'token_id', - { name: 'block_height', sort: 'DESC' }, - { name: 'tx_index', sort: 'DESC' }, - { name: 'event_index', sort: 'DESC' }, - ], - { where: "update_mode = 'dynamic'" } - ); -} diff --git a/migrations/1744225682001_ft-lower-index.ts b/migrations/1744225682001_ft-lower-index.ts deleted file mode 100644 index a0740b27..00000000 --- a/migrations/1744225682001_ft-lower-index.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate'; - -export const shorthands: ColumnDefinitions | undefined = undefined; - -export function up(pgm: MigrationBuilder): void { - pgm.dropIndex('tokens', ['type', 'name']); - pgm.createIndex('tokens', ['type', 'LOWER(name)'], { where: "type = 'ft'" }); - - pgm.dropIndex('tokens', ['type', 'symbol']); - pgm.createIndex('tokens', ['type', 'LOWER(symbol)'], { where: "type = 'ft'" }); -} - -export function down(pgm: MigrationBuilder): void { - pgm.dropIndex('tokens', ['type', 'LOWER(name)']); - pgm.createIndex('tokens', ['type', 'name'], { where: "type = 'ft'" }); - - pgm.dropIndex('tokens', ['type', 'LOWER(symbol)']); - pgm.createIndex('tokens', ['type', 'symbol'], { where: "type = 'ft'" }); -}