terra-money / fcd-classic

Terra ETL + RestFul API Server
https://fcd.terra.dev/swagger
MIT License
63 stars 42 forks source link

Columbus-5 update #143

Closed hanjukim closed 2 years ago

hanjukim commented 3 years ago

Description

This PR has several updates for Columbus-5 which has been tested in testnet and mainnet for a while. Most of the changes are due to Core changes and are breaking changes. If you are migrating existing FCD database from Columbus-4 or Tequila-0004, you need to take some time to compare required changes through typeorm migration:generate command. DO NOT apply it without a careful review and knowing how it will affect the database.

Assuming that the database of Columbus-4 or Tequila-004 matched the previous version of ORM scheme, refer to the script below.

ALTER TABLE "wasm_contract" ADD "creator" character varying;
UPDATE "wasm_contract" SET "creator"=owner;
UPDATE "wasm_contract" SET "admin"='' WHERE "migratable"=false;
ALTER TABLE "wasm_contract" DROP COLUMN "migratable";
ALTER TABLE "wasm_contract" ALTER COLUMN "owner" DROP NOT NULL;
ALTER TABLE "wasm_contract" ALTER COLUMN "init_msg" DROP NOT NULL;
ALTER TABLE "wasm_contract" ALTER COLUMN "tx_hash" DROP NOT NULL;
ALTER TABLE "wasm_contract" ALTER COLUMN "tx_memo" DROP NOT NULL;
ALTER TABLE "wasm_contract" ALTER COLUMN "timestamp" DROP NOT NULL;
ALTER TABLE "wasm_contract" ALTER COLUMN "timestamp" SET DEFAULT now();
ALTER TABLE "wasm_code" ALTER COLUMN "timestamp" SET DEFAULT now();
ALTER TABLE "validator_info" DROP COLUMN "consensus_pubkey";
ALTER TABLE "validator_info" ADD "security_contact" character varying NOT NULL DEFAULT '';
ALTER TABLE "validator_info" ALTER COLUMN "jailed" DROP NOT NULL;
ALTER TABLE "validator_info" ALTER COLUMN "jailed" SET DEFAULT false;
ALTER TABLE "validator_info" ALTER COLUMN "signing_info" DROP NOT NULL;
ALTER TABLE "validator_info" ALTER COLUMN "reward_pool" DROP NOT NULL;
ALTER TABLE "account_tx" ALTER COLUMN "id" type bigint;
ALTER TABLE "account_tx" DROP COLUMN "hash";
ALTER TABLE "account_tx" DROP COLUMN "type";
ALTER TABLE "account_tx" DROP COLUMN "chain_id";
ALTER TABLE "richlist" ALTER COLUMN "id" type bigint;
DELETE FROM "block" WHERE "chain_id"='tequila-0004' AND "height" > 5330000;

Changes