-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
indexer: drop concept of transaction id, hash is now the primary key
* api: remove endpoint /chain/transactions/reference/index/{index} indexer migration: * 0013_recreate_table_transactions.sql
- Loading branch information
Showing
10 changed files
with
65 additions
and
112 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
56 changes: 56 additions & 0 deletions
56
vochain/indexer/migrations/0013_recreate_table_transactions.sql
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,56 @@ | ||
-- +goose Up | ||
PRAGMA foreign_keys = OFF; | ||
|
||
-- Create a new table with hash as primary key | ||
CREATE TABLE transactions_new ( | ||
hash BLOB NOT NULL PRIMARY KEY, | ||
block_height INTEGER NOT NULL, | ||
block_index INTEGER NOT NULL, | ||
type TEXT NOT NULL | ||
); | ||
|
||
-- Copy data from the old table to the new table | ||
INSERT INTO transactions_new (hash, block_height, block_index, type) | ||
SELECT hash, block_height, block_index, type | ||
FROM transactions; | ||
|
||
-- Drop the old table | ||
DROP TABLE transactions; | ||
|
||
-- Rename the new table to the old table name | ||
ALTER TABLE transactions_new RENAME TO transactions; | ||
|
||
-- Recreate necessary indexes | ||
CREATE INDEX transactions_block_height_index | ||
ON transactions(block_height, block_index); | ||
|
||
PRAGMA foreign_keys = ON; | ||
|
||
-- +goose Down | ||
PRAGMA foreign_keys = OFF; | ||
|
||
-- Recreate the old table structure | ||
CREATE TABLE transactions ( | ||
id INTEGER NOT NULL PRIMARY KEY, | ||
hash BLOB NOT NULL, | ||
block_height INTEGER NOT NULL, | ||
block_index INTEGER NOT NULL, | ||
type TEXT NOT NULL | ||
); | ||
|
||
-- Copy data back from the new table to the old table | ||
INSERT INTO transactions (hash, block_height, block_index, type) | ||
SELECT hash, block_height, block_index, type | ||
FROM transactions_new; | ||
|
||
-- Drop the new table | ||
DROP TABLE transactions_new; | ||
|
||
-- Recreate the old indexes | ||
CREATE INDEX transactions_hash | ||
ON transactions(hash); | ||
|
||
CREATE INDEX transactions_block_height_index | ||
ON transactions(block_height, block_index); | ||
|
||
PRAGMA foreign_keys = ON; |
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