code.vegaprotocol.io/vega@v0.79.0/datanode/sqlstore/migrations/0101_secondary_bridge.sql (about) 1 -- +goose Up 2 3 DROP VIEW IF EXISTS assets_current; 4 5 ALTER TABLE assets 6 ADD COLUMN IF NOT EXISTS chain_id VARCHAR NOT NULL default ''; 7 8 ALTER TABLE erc20_multisig_signer_events 9 ADD COLUMN IF NOT EXISTS chain_id VARCHAR NOT NULL default ''; 10 11 CREATE VIEW assets_current AS 12 ( 13 SELECT DISTINCT ON (id) * 14 FROM assets 15 ORDER BY id, vega_time DESC 16 ); 17 18 -- +goose StatementBegin 19 DO 20 $$ 21 DECLARE 22 primary_chain_id VARCHAR; 23 BEGIN 24 -- All existing assets come have been enable on the primary bridge. 25 -- So it's safe to update all assets with the chain ID configured in the 26 -- network parameters. 27 SELECT value::JSONB ->> 'chain_id' as chain_id 28 INTO primary_chain_id 29 FROM network_parameters_current 30 WHERE key = 'blockchains.ethereumConfig'; 31 32 UPDATE assets SET chain_id = primary_chain_id; 33 UPDATE erc20_multisig_signer_events SET chain_id = primary_chain_id; 34 END; 35 $$; 36 -- +goose StatementEnd 37 38 39 -- +goose Down 40 DROP VIEW IF EXISTS assets_current; 41 42 ALTER TABLE assets 43 DROP COLUMN IF EXISTS chain_id; 44 45 CREATE VIEW assets_current AS 46 ( 47 SELECT DISTINCT ON (id) * 48 FROM assets 49 ORDER BY id, vega_time DESC 50 ); 51 52 53 ALTER TABLE erc20_multisig_signer_events 54 DROP COLUMN IF EXISTS chain_id;