Skip to content

Commit

Permalink
Updated to use ascending order index
Browse files Browse the repository at this point in the history
  • Loading branch information
jairajdev committed Jul 19, 2024
1 parent d2ffd61 commit 210bb7a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/dbstore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ export const initializeDB = async (config: Config): Promise<void> => {
'CREATE TABLE if not exists `transactions` (`txId` TEXT NOT NULL UNIQUE PRIMARY KEY, `appReceiptId` TEXT, `timestamp` BIGINT NOT NULL, `cycleNumber` NUMBER NOT NULL, `data` JSON NOT NULL, `originalTxData` JSON NOT NULL)'
)
await db.runCreate(
'CREATE INDEX if not exists `transactions_cycleNumber` ON `transactions` (`cycleNumber` DESC)'
'CREATE INDEX if not exists `transactions_cycleNumber` ON `transactions` (`cycleNumber` ASC)'
)
await db.runCreate(
'CREATE INDEX if not exists `transactions_timestamp` ON `transactions` (`timestamp` DESC)'
'CREATE INDEX if not exists `transactions_timestamp` ON `transactions` (`timestamp` ASC)'
)
await db.runCreate(
'CREATE INDEX if not exists `transactions_appReceiptId_idx` ON `transactions` (`appReceiptId`)'
)
await db.runCreate(
'CREATE TABLE if not exists `cycles` (`cycleMarker` TEXT NOT NULL UNIQUE PRIMARY KEY, `counter` NUMBER NOT NULL, `cycleRecord` JSON NOT NULL)'
)
await db.runCreate('CREATE INDEX if not exists `cycles_idx` ON `cycles` (`counter` DESC)')
await db.runCreate('CREATE INDEX if not exists `cycles_idx` ON `cycles` (`counter` ASC)')
await db.runCreate(
'CREATE TABLE if not exists `accounts` (`accountId` TEXT NOT NULL UNIQUE PRIMARY KEY, `data` JSON NOT NULL, `timestamp` BIGINT NOT NULL, `hash` TEXT NOT NULL, `cycleNumber` NUMBER NOT NULL, `isGlobal` BOOLEAN NOT NULL)'
)
await db.runCreate('CREATE INDEX if not exists `accounts_cycleNumber` ON `accounts` (`cycleNumber` DESC)')
await db.runCreate('CREATE INDEX if not exists `accounts_timestamp` ON `accounts` (`timestamp` DESC)')
await db.runCreate('CREATE INDEX if not exists `accounts_cycleNumber` ON `accounts` (`cycleNumber` ASC)')
await db.runCreate('CREATE INDEX if not exists `accounts_timestamp` ON `accounts` (`timestamp` ASC)')
await db.runCreate(
'CREATE TABLE if not exists `receipts` (`receiptId` TEXT NOT NULL UNIQUE PRIMARY KEY, `tx` JSON NOT NULL, `cycle` NUMBER NOT NULL, `timestamp` BIGINT NOT NULL, `beforeStateAccounts` JSON, `accounts` JSON NOT NULL, `appliedReceipt` JSON NOT NULL, `appReceiptData` JSON, `executionShardKey` TEXT NOT NULL, `globalModification` BOOLEAN NOT NULL)'
)
Expand Down

0 comments on commit 210bb7a

Please sign in to comment.