From a3df5f855f2760e2f4f304027b0b9627451e62a3 Mon Sep 17 00:00:00 2001 From: affan Date: Fri, 18 Oct 2024 18:56:44 -0400 Subject: [PATCH] update migration to stop excessive consumption of computation --- ...1410_change_fills_affiliaterevshare_type.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/indexer/packages/postgres/src/db/migrations/migration_files/20240910101410_change_fills_affiliaterevshare_type.ts b/indexer/packages/postgres/src/db/migrations/migration_files/20240910101410_change_fills_affiliaterevshare_type.ts index dd61af5d3b..96d7b48083 100644 --- a/indexer/packages/postgres/src/db/migrations/migration_files/20240910101410_change_fills_affiliaterevshare_type.ts +++ b/indexer/packages/postgres/src/db/migrations/migration_files/20240910101410_change_fills_affiliaterevshare_type.ts @@ -2,15 +2,21 @@ import * as Knex from 'knex'; // No data has been stored added at time of commit export async function up(knex: Knex): Promise { - return knex.schema.alterTable('fills', (table) => { - // decimal('columnName') has is 8,2 precision and scale - // decimal('columnName', null) has variable precision and scale - table.decimal('affiliateRevShare', null).notNullable().defaultTo(0).alter(); + // decimal('columnName') has is 8,2 precision and scale + // decimal('columnName', null) has variable precision and scale + await knex.schema.alterTable('fills', (table) => { + table.dropColumn('affiliateRevShare'); + }); + await knex.schema.alterTable('fills', (table) => { + table.decimal('affiliateRevShare', null).notNullable().defaultTo(0); }); } export async function down(knex: Knex): Promise { - return knex.schema.alterTable('fills', (table) => { - table.string('affiliateRevShare').notNullable().defaultTo('0').alter(); + await knex.schema.alterTable('fills', (table) => { + table.dropColumn('affiliateRevShare'); + }); + await knex.schema.alterTable('fills', (table) => { + table.string('affiliateRevShare').notNullable().defaultTo('0'); }); }