[indexing] make blocks.definition_hash nullable
This commit is contained in:
		
							parent
							
								
									79339c0589
								
							
						
					
					
						commit
						b5d5231bc1
					
				| @ -7,7 +7,7 @@ import cpfpRepository from '../repositories/CpfpRepository'; | |||||||
| import { RowDataPacket } from 'mysql2'; | import { RowDataPacket } from 'mysql2'; | ||||||
| 
 | 
 | ||||||
| class DatabaseMigration { | class DatabaseMigration { | ||||||
|   private static currentVersion = 95; |   private static currentVersion = 96; | ||||||
|   private queryTimeout = 3600_000; |   private queryTimeout = 3600_000; | ||||||
|   private statisticsAddedIndexed = false; |   private statisticsAddedIndexed = false; | ||||||
|   private uniqueLogs: string[] = []; |   private uniqueLogs: string[] = []; | ||||||
| @ -1121,7 +1121,7 @@ class DatabaseMigration { | |||||||
| 
 | 
 | ||||||
|     // blocks pools-v2.json hash
 |     // blocks pools-v2.json hash
 | ||||||
|     if (databaseSchemaVersion < 95) { |     if (databaseSchemaVersion < 95) { | ||||||
|       let poolJsonSha = 'f737d86571d190cf1a1a3cf5fd86b33ba9624254'; |       let poolJsonSha = 'f737d86571d190cf1a1a3cf5fd86b33ba9624254'; // https://github.com/mempool/mining-pools/commit/f737d86571d190cf1a1a3cf5fd86b33ba9624254
 | ||||||
|       const [poolJsonShaDb]: any[] = await DB.query(`SELECT string FROM state WHERE name = 'pools_json_sha'`); |       const [poolJsonShaDb]: any[] = await DB.query(`SELECT string FROM state WHERE name = 'pools_json_sha'`); | ||||||
|       if (poolJsonShaDb?.length > 0) { |       if (poolJsonShaDb?.length > 0) { | ||||||
|         poolJsonSha = poolJsonShaDb[0].string; |         poolJsonSha = poolJsonShaDb[0].string; | ||||||
| @ -1130,6 +1130,17 @@ class DatabaseMigration { | |||||||
|       await this.$executeQuery('ALTER TABLE blocks ADD INDEX `definition_hash` (`definition_hash`)'); |       await this.$executeQuery('ALTER TABLE blocks ADD INDEX `definition_hash` (`definition_hash`)'); | ||||||
|       await this.updateToSchemaVersion(95); |       await this.updateToSchemaVersion(95); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     // Make definition_hash nullable
 | ||||||
|  |     if (databaseSchemaVersion < 96) { | ||||||
|  |       let poolJsonSha = '0138019f39e0f6033db576be15a4880a216c1dd0'; // https://github.com/mempool/mining-pools/commit/0138019f39e0f6033db576be15a4880a216c1dd0
 | ||||||
|  |       const [poolJsonShaDb]: any[] = await DB.query(`SELECT string FROM state WHERE name = 'pools_json_sha'`); | ||||||
|  |       if (poolJsonShaDb?.length > 0) { | ||||||
|  |         poolJsonSha = poolJsonShaDb[0].string; | ||||||
|  |       } | ||||||
|  |       await this.$executeQuery(`ALTER TABLE blocks MODIFY COLUMN definition_hash varchar(255) NULL DEFAULT "${poolJsonSha}"`); | ||||||
|  |       await this.updateToSchemaVersion(96); | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user