-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add updatedHeight on provider table and fix indexer (#38)
* Add updatedHeight on provider table and fix indexer * Bump indexer version * Prepare for PR
- Loading branch information
Showing
5 changed files
with
39 additions
and
4 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,34 @@ | ||
# Upgrade instructions | ||
|
||
Some indexer updates changes the database schemas and an upgrade script must be run on the database to migrate the data before or after updating the indexer. Here is a list of those migrations. If a version is not listed here it means the indexer can be updated without any manual migration. | ||
|
||
## v1.5.0 | ||
|
||
Version 1.5.0 adds an `updatedHeight` field to Akash's `Provider` table and fixes a bug that was updating the `createdHeight` on provider updates. This script need to be run before updating the indexer to v1.5.0. | ||
|
||
``` | ||
-- Add updatedHeight column to provider table | ||
ALTER TABLE IF EXISTS "provider" ADD COLUMN "updatedHeight" integer; | ||
-- Set correct values for createdHeight and updatedHeight | ||
WITH "created_msg" AS ( | ||
SELECT m."height",ar."address" | ||
FROM "message" m | ||
INNER JOIN "transaction" t ON t.id=m."txId" | ||
INNER JOIN "addressReference" ar ON ar."transactionId"=t."id" | ||
WHERE t."hasProcessingError" IS FALSE AND m."type" LIKE '/akash.provider.%.MsgCreateProvider' AND ar."type"='Signer' | ||
), | ||
"update_msg" AS ( | ||
SELECT MAX(m."height") AS "height",ar."address" | ||
FROM "message" m | ||
INNER JOIN "transaction" t ON t.id=m."txId" | ||
INNER JOIN "addressReference" ar ON ar."transactionId"=t."id" | ||
WHERE t."hasProcessingError" IS FALSE AND m."type" LIKE '/akash.provider.%.MsgUpdateProvider' AND ar."type"='Signer' | ||
GROUP BY ar."address" | ||
) | ||
UPDATE "provider" p | ||
SET "createdHeight"=cm."height", "updatedHeight"=um."height" | ||
FROM "created_msg" cm | ||
LEFT JOIN "update_msg" um ON um."address"=cm."address" | ||
WHERE cm."address"=p."owner"; | ||
``` |
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
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