#!/bin/bash

echo "Beginning parallel regingest at `date`"
echo "disable triggers to prevent deadlocks - see https://bugs.launchpad.net/evergreen/+bug/1931737"

# NB: You may need to add username and other connection options for the psql commands.
# Disable the triggers.
psql <<EOF
ALTER TABLE metabib.title_field_entry DISABLE TRIGGER maintain_symspell_entries_tgr;
ALTER TABLE metabib.author_field_entry DISABLE TRIGGER maintain_symspell_entries_tgr;
ALTER TABLE metabib.subject_field_entry DISABLE TRIGGER maintain_symspell_entries_tgr;
ALTER TABLE metabib.series_field_entry DISABLE TRIGGER maintain_symspell_entries_tgr;
ALTER TABLE metabib.keyword_field_entry DISABLE TRIGGER maintain_symspell_entries_tgr;
ALTER TABLE metabib.identifier_field_entry DISABLE TRIGGER maintain_symspell_entries_tgr;
EOF

# Adjust the options below as appropriate for your data:
time pingest.pl --batch-size 10000 --max-child 8 --skip-browse

# Re-enable the triggers
psql <<EOF
ALTER TABLE metabib.title_field_entry ENABLE TRIGGER maintain_symspell_entries_tgr;
ALTER TABLE metabib.author_field_entry ENABLE TRIGGER maintain_symspell_entries_tgr;
ALTER TABLE metabib.subject_field_entry ENABLE TRIGGER maintain_symspell_entries_tgr;
ALTER TABLE metabib.series_field_entry ENABLE TRIGGER maintain_symspell_entries_tgr;
ALTER TABLE metabib.keyword_field_entry ENABLE TRIGGER maintain_symspell_entries_tgr;
ALTER TABLE metabib.identifier_field_entry ENABLE TRIGGER maintain_symspell_entries_tgr;
EOF
