-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add output to current locations and block_hash to inscriptions
- Loading branch information
Showing
6 changed files
with
65 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* 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('inscriptions', { | ||
block_hash: { | ||
type: 'text', | ||
}, | ||
}); | ||
pgm.sql(` | ||
UPDATE inscriptions SET block_hash = ( | ||
SELECT block_hash FROM locations AS l WHERE l.ordinal_number = ordinal_number LIMIT 1 | ||
) | ||
`); | ||
pgm.alterColumn('inscriptions', 'block_hash', { notNull: true }); | ||
} | ||
|
||
export function down(pgm: MigrationBuilder): void { | ||
pgm.dropColumn('inscriptions', 'block_hash'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* 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('current_locations', { | ||
output: { | ||
type: 'text', | ||
}, | ||
}); | ||
pgm.sql(` | ||
UPDATE current_locations SET output = ( | ||
SELECT output FROM locations AS l | ||
WHERE l.ordinal_number = ordinal_number | ||
AND l.block_height = block_height | ||
AND l.tx_index = tx_index | ||
LIMIT 1 | ||
) | ||
`); | ||
pgm.alterColumn('current_locations', 'output', { notNull: true }); | ||
} | ||
|
||
export function down(pgm: MigrationBuilder): void { | ||
pgm.dropColumn('current_locations', 'output'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters