Skip to content

Commit

Permalink
fix: total
Browse files Browse the repository at this point in the history
  • Loading branch information
rvcas committed Aug 31, 2024
1 parent 5cd0ad4 commit 6b03da2
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ CREATE TABLE `blocks` (
`nonce` text(64),
`miner_cred` text,
`nft_cred` text(120),
`data` text
`data` text,
`cardano_tx_hash` text(64) NOT NULL,
`cardano_slot` integer NOT NULL,
`cardano_hash` text(64) NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `blocks_hash_unique` ON `blocks` (`hash`);
CREATE UNIQUE INDEX `blocks_hash_unique` ON `blocks` (`hash`);--> statement-breakpoint
CREATE UNIQUE INDEX `blocks_cardano_tx_hash_unique` ON `blocks` (`cardano_tx_hash`);
30 changes: 29 additions & 1 deletion migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "b051fed5-1dde-419a-ac35-ca7a3642a698",
"id": "16a4f861-0912-436e-9831-6ecf6bdbf614",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"blocks": {
Expand Down Expand Up @@ -76,6 +76,27 @@
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"cardano_tx_hash": {
"name": "cardano_tx_hash",
"type": "text(64)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"cardano_slot": {
"name": "cardano_slot",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"cardano_hash": {
"name": "cardano_hash",
"type": "text(64)",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
Expand All @@ -85,6 +106,13 @@
"hash"
],
"isUnique": true
},
"blocks_cardano_tx_hash_unique": {
"name": "blocks_cardano_tx_hash_unique",
"columns": [
"cardano_tx_hash"
],
"isUnique": true
}
},
"foreignKeys": {},
Expand Down
4 changes: 2 additions & 2 deletions migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{
"idx": 0,
"version": "6",
"when": 1721177302472,
"tag": "0000_friendly_bromley",
"when": 1725056292226,
"tag": "0000_lush_rictor",
"breakpoints": true
}
]
Expand Down
3 changes: 3 additions & 0 deletions src/lib/server/schema.sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ export const blocks = sqliteTable('blocks', {
paymentCred: text('miner_cred'),
nftCred: text('nft_cred', { length: 120 }),
data: text('data'),
cardano_tx_hash: text('cardano_tx_hash', { length: 64 }).notNull().unique(),
cardano_slot: integer('cardano_slot').notNull(),
cardano_hash: text('cardano_hash', { length: 64 }).notNull(),
});
2 changes: 1 addition & 1 deletion src/routes/explorer/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function load({ url, platform }: PageServerLoadEvent) {
offset: (parsedPageNumber - 1) * parsedPageLimit,
});

const result = await db.select({ count: count() }).from(schema.blocks);
const result = await db.select({ count: count(schema.blocks.number) }).from(schema.blocks);

const totalCount = result[0].count;

Expand Down

0 comments on commit 6b03da2

Please sign in to comment.