forked from FuelLabs/fuel-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: index assets contracts (FuelLabs#576)
- Loading branch information
1 parent
a8b03bc
commit 3298951
Showing
1 changed file
with
41 additions
and
0 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,41 @@ | ||
import { DatabaseConnection } from '../../../src/infra/database/DatabaseConnection'; | ||
|
||
async function migrate() { | ||
const db = DatabaseConnection.getInstance(); | ||
|
||
await db.query( | ||
` | ||
DROP TABLE IF EXISTS indexer.block_statistics; | ||
`, | ||
[], | ||
); | ||
console.log('Dropped block_statistics table if it existed.'); | ||
// Step 3: Create the blocks table | ||
await db.query( | ||
` | ||
CREATE TABLE indexer.block_statistics ( | ||
id SERIAL PRIMARY KEY, | ||
timestamp TIMESTAMP NOT NULL, | ||
number_of_blocks INTEGER NOT NULL, | ||
cumulative_block_reward NUMERIC NOT NULL, | ||
start_block INTEGER NOT NULL, | ||
end_block INTEGER NOT NULL | ||
); | ||
`, | ||
[], | ||
); | ||
|
||
// Step 16: Create indexes for transactions_accounts table | ||
await db.query( | ||
` | ||
CREATE UNIQUE INDEX ON indexer.block_statistics(id); | ||
CREATE INDEX ON indexer.block_statistics(timestamp); | ||
`, | ||
[], | ||
); | ||
console.log('Indexes for transactions_accounts table created successfully.'); | ||
} | ||
|
||
migrate() | ||
.catch(console.error) | ||
.finally(() => process.exit()); |