-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from hirosystems/beta
merge beta into develop
- Loading branch information
Showing
27 changed files
with
2,149 additions
and
1,625 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* 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('chain_tip', { | ||
inscription_count: { | ||
type: 'int', | ||
notNull: true, | ||
default: 0, | ||
}, | ||
}); | ||
} |
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,32 @@ | ||
/* 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.alterColumn('inscriptions', 'id', { type: 'bigint' }); | ||
pgm.alterColumn('inscriptions', 'number', { type: 'bigint' }); | ||
pgm.alterColumn('inscriptions', 'content_length', { type: 'bigint' }); | ||
|
||
pgm.alterColumn('locations', 'id', { type: 'bigint' }); | ||
pgm.alterColumn('locations', 'inscription_id', { type: 'bigint' }); | ||
pgm.alterColumn('locations', 'block_height', { type: 'bigint' }); | ||
pgm.alterColumn('locations', 'sat_coinbase_height', { type: 'bigint' }); | ||
|
||
pgm.alterColumn('json_contents', 'id', { type: 'bigint' }); | ||
pgm.alterColumn('json_contents', 'inscription_id', { type: 'bigint' }); | ||
} | ||
|
||
export function down(pgm: MigrationBuilder): void { | ||
pgm.alterColumn('inscriptions', 'id', { type: 'int' }); | ||
pgm.alterColumn('inscriptions', 'number', { type: 'int' }); | ||
pgm.alterColumn('inscriptions', 'content_length', { type: 'int' }); | ||
|
||
pgm.alterColumn('locations', 'id', { type: 'int' }); | ||
pgm.alterColumn('locations', 'inscription_id', { type: 'int' }); | ||
pgm.alterColumn('locations', 'block_height', { type: 'int' }); | ||
pgm.alterColumn('locations', 'sat_coinbase_height', { type: 'int' }); | ||
|
||
pgm.alterColumn('json_contents', 'id', { type: 'int' }); | ||
pgm.alterColumn('json_contents', 'inscription_id', { type: 'int' }); | ||
} |
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,12 @@ | ||
/* 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.createMaterializedView( | ||
'mime_type_counts', | ||
{ data: true }, | ||
`SELECT mime_type, COUNT(*) AS count FROM inscriptions GROUP BY mime_type` | ||
); | ||
} |
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,18 @@ | ||
/* 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.createMaterializedView( | ||
'sat_rarity_counts', | ||
{ data: true }, | ||
` | ||
SELECT sat_rarity, COUNT(*) AS count | ||
FROM inscriptions AS i | ||
INNER JOIN locations AS loc ON loc.inscription_id = i.id | ||
WHERE loc.current = TRUE | ||
GROUP BY sat_rarity | ||
` | ||
); | ||
} |
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,12 @@ | ||
/* 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.createMaterializedView( | ||
'inscription_count', | ||
{ data: true }, | ||
`SELECT COUNT(*) AS count FROM inscriptions` | ||
); | ||
} |
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,38 @@ | ||
/* 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.dropTable('chain_tip'); | ||
pgm.createMaterializedView( | ||
'chain_tip', | ||
{ data: true }, | ||
`SELECT GREATEST(MAX(block_height), 767430) AS block_height FROM locations` | ||
); | ||
} | ||
|
||
export function down(pgm: MigrationBuilder): void { | ||
pgm.dropMaterializedView('chain_tip'); | ||
pgm.createTable('chain_tip', { | ||
id: { | ||
type: 'bool', | ||
primaryKey: true, | ||
default: true, | ||
}, | ||
block_height: { | ||
type: 'int', | ||
notNull: true, | ||
default: 767430, // First inscription block height | ||
}, | ||
inscription_count: { | ||
type: 'int', | ||
notNull: true, | ||
default: 0, | ||
}, | ||
}); | ||
// Ensure only a single row can exist | ||
pgm.addConstraint('chain_tip', 'chain_tip_one_row', 'CHECK(id)'); | ||
// Create the single row | ||
pgm.sql('INSERT INTO chain_tip VALUES(DEFAULT)'); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.