merge forensics columns into main channels table

This commit is contained in:
Mononaut
2022-11-25 15:54:44 +09:00
committed by softsimon
parent 609f68eb24
commit ded11892f5
3 changed files with 39 additions and 89 deletions

View File

@@ -382,7 +382,15 @@ class DatabaseMigration {
if (databaseSchemaVersion < 48 && isBitcoin === true) {
await this.$executeQuery('ALTER TABLE `channels` ADD source_checked tinyint(1) DEFAULT 0');
await this.$executeQuery(this.getCreateChannelsForensicsTableQuery(), await this.$checkIfTableExists('channels_forensics'));
await this.$executeQuery('ALTER TABLE `channels` ADD closing_fee bigint(20) unsigned DEFAULT 0');
await this.$executeQuery('ALTER TABLE `channels` ADD node1_funding_balance bigint(20) unsigned DEFAULT 0');
await this.$executeQuery('ALTER TABLE `channels` ADD node2_funding_balance bigint(20) unsigned DEFAULT 0');
await this.$executeQuery('ALTER TABLE `channels` ADD node1_closing_balance bigint(20) unsigned DEFAULT 0');
await this.$executeQuery('ALTER TABLE `channels` ADD node2_closing_balance bigint(20) unsigned DEFAULT 0');
await this.$executeQuery('ALTER TABLE `channels` ADD funding_ratio float unsigned 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 outputs JSON DEFAULT "[]"');
}
}
@@ -764,25 +772,6 @@ class DatabaseMigration {
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
}
private getCreateChannelsForensicsTableQuery(): string {
return `CREATE TABLE IF NOT EXISTS channels_forensics (
channel_id bigint(11) unsigned NOT NULL,
closing_fee bigint(20) unsigned DEFAULT 0,
node1_funding_balance bigint(20) unsigned DEFAULT 0,
node2_funding_balance bigint(20) unsigned DEFAULT 0,
node1_closing_balance bigint(20) unsigned DEFAULT 0,
node2_closing_balance bigint(20) unsigned DEFAULT 0,
funding_ratio float unsigned DEFAULT NULL,
closed_by varchar(66) DEFAULT NULL,
single_funded tinyint(1) default 0,
outputs JSON NOT NULL,
PRIMARY KEY (channel_id),
FOREIGN KEY (channel_id)
REFERENCES channels (id)
ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
}
private getCreateNodesStatsQuery(): string {
return `CREATE TABLE IF NOT EXISTS node_stats (
id int(11) unsigned NOT NULL AUTO_INCREMENT,