block audit truncation in separate db migrations. bump timeout to 1 hour.

This commit is contained in:
Mononaut 2022-11-24 19:31:10 +09:00 committed by softsimon
parent ead60aaa21
commit 03a3320e45
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7

View File

@ -4,8 +4,8 @@ import logger from '../logger';
import { Common } from './common'; import { Common } from './common';
class DatabaseMigration { class DatabaseMigration {
private static currentVersion = 48; private static currentVersion = 49;
private queryTimeout = 900_000; private queryTimeout = 3600_000;
private statisticsAddedIndexed = false; private statisticsAddedIndexed = false;
private uniqueLogs: string[] = []; private uniqueLogs: string[] = [];
@ -403,23 +403,25 @@ class DatabaseMigration {
} }
if (databaseSchemaVersion < 44 && isBitcoin === true) { if (databaseSchemaVersion < 44 && isBitcoin === true) {
await this.$executeQuery('TRUNCATE TABLE `blocks_audits`');
await this.$executeQuery('UPDATE blocks_summaries SET template = NULL'); await this.$executeQuery('UPDATE blocks_summaries SET template = NULL');
this.updateToSchemaVersion(44); this.updateToSchemaVersion(44);
} }
if (databaseSchemaVersion < 45 && isBitcoin === true) { if (databaseSchemaVersion < 45 && isBitcoin === true) {
await this.$executeQuery('ALTER TABLE `blocks_audits` ADD fresh_txs JSON DEFAULT "[]"'); await this.$executeQuery('ALTER TABLE `blocks_audits` ADD fresh_txs JSON DEFAULT "[]"');
this.updateToSchemaVersion(45);
} }
if (databaseSchemaVersion < 46) { if (databaseSchemaVersion < 46) {
await this.$executeQuery(`ALTER TABLE blocks MODIFY blockTimestamp timestamp NOT NULL DEFAULT 0`); await this.$executeQuery(`ALTER TABLE blocks MODIFY blockTimestamp timestamp NOT NULL DEFAULT 0`);
this.updateToSchemaVersion(46);
} }
if (databaseSchemaVersion < 47) { if (databaseSchemaVersion < 47) {
await this.$executeQuery('ALTER TABLE `blocks` ADD cpfp_indexed tinyint(1) DEFAULT 0'); await this.$executeQuery('ALTER TABLE `blocks` ADD cpfp_indexed tinyint(1) DEFAULT 0');
await this.$executeQuery(this.getCreateCPFPTableQuery(), await this.$checkIfTableExists('cpfp_clusters')); await this.$executeQuery(this.getCreateCPFPTableQuery(), await this.$checkIfTableExists('cpfp_clusters'));
await this.$executeQuery(this.getCreateTransactionsTableQuery(), await this.$checkIfTableExists('transactions')); await this.$executeQuery(this.getCreateTransactionsTableQuery(), await this.$checkIfTableExists('transactions'));
this.updateToSchemaVersion(47);
} }
if (databaseSchemaVersion < 48 && isBitcoin === true) { if (databaseSchemaVersion < 48 && isBitcoin === true) {
@ -433,6 +435,12 @@ class DatabaseMigration {
await this.$executeQuery('ALTER TABLE `channels` ADD closed_by varchar(66) DEFAULT NULL'); await this.$executeQuery('ALTER TABLE `channels` ADD closed_by varchar(66) DEFAULT NULL');
await this.$executeQuery('ALTER TABLE `channels` ADD single_funded tinyint(1) DEFAULT 0'); await this.$executeQuery('ALTER TABLE `channels` ADD single_funded tinyint(1) DEFAULT 0');
await this.$executeQuery('ALTER TABLE `channels` ADD outputs JSON DEFAULT "[]"'); await this.$executeQuery('ALTER TABLE `channels` ADD outputs JSON DEFAULT "[]"');
this.updateToSchemaVersion(48);
}
if (databaseSchemaVersion < 49 && isBitcoin === true) {
await this.$executeQuery('TRUNCATE TABLE `blocks_audits`');
this.updateToSchemaVersion(49);
} }
} }