Skip to content

Commit

Permalink
fix: add migration to remove old chainwatch schema constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
iand committed Oct 1, 2020
1 parent 88b71f7 commit 696c227
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
# vendor/
.idea
visor
sentinel-visor

build/.*
37 changes: 37 additions & 0 deletions storage/migrations/4_drop_chainwatch_constraints.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package migrations

import (
"github.com/go-pg/migrations/v8"
)

// Schema version 4 removes foreign key constraints from the original chainwatch schema which interfere with parallel inserts

func init() {

up := batch(`
ALTER TABLE public.drand_block_entries DROP CONSTRAINT IF EXISTS block_drand_entries_drand_entries_round_fk;
ALTER TABLE public.drand_block_entries DROP CONSTRAINT IF EXISTS blocks_block_cids_cid_fk;
ALTER TABLE public.blocks_synced DROP CONSTRAINT IF EXISTS blocks_block_cids_cid_fk;
ALTER TABLE public.block_headers DROP CONSTRAINT IF EXISTS blocks_block_cids_cid_fk;
ALTER TABLE public.block_parents DROP CONSTRAINT IF EXISTS blocks_block_cids_cid_fk;
ALTER TABLE public.block_messages DROP CONSTRAINT IF EXISTS blocks_block_cids_cid_fk;
ALTER TABLE public.minerid_dealid_sectorid DROP CONSTRAINT IF EXISTS sectors_sector_ids_id_fk;
ALTER TABLE public.minerid_dealid_sectorid DROP CONSTRAINT IF EXISTS minerid_dealid_sectorid_sector_id_fkey;
ALTER TABLE public.actors DROP CONSTRAINT IF EXISTS id_address_map_actors_id_fk;
ALTER TABLE public.mpool_messages DROP CONSTRAINT IF EXISTS mpool_messages_messages_cid_fk;
`)

// Note that it is infeasble to add these constraints back after they have been removed since they will almost certainly fail
// to be met, especially since we do not populate block_cids table any more.
down := batch("SELECT 1;")

migrations.MustRegisterTx(up, down)

}

0 comments on commit 696c227

Please sign in to comment.