Skip to content

Commit

Permalink
feat: index assets contracts (FuelLabs#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigobranas authored and raghukapur9 committed Sep 25, 2024
1 parent a8b03bc commit 3298951
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/graphql/database/migrations/db/migrate.ts
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());

0 comments on commit 3298951

Please sign in to comment.