#!/bin/sh # This is a workaround for an error that occurs when running 'nfldb-update' where some of the JSON data it # gets from the internet contains "JAX" instead of "JAC" as the key for the Jacksonville Jaguars team # Workaround # Temporarily add a new team with the bad key psql --username=nfldb nfldb --command="INSERT INTO team VALUES ('JAX', 'Jacksonville', 'Jaguars')" # Run nfldb-update - shouldn't have the error since it finds a matching team with bad key, "JAX" nfldb-update # Check which tables have been populated with the bad key: psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM play WHERE pos_team = 'JAX'" psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM drive WHERE pos_team = 'JAX'" psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM game WHERE home_team = 'JAX'" psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM game WHERE away_team = 'JAX'" psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM player WHERE team = 'JAX'" psql --username=nfldb nfldb --command="SELECT COUNT(*) FROM play_player WHERE team = 'JAX'" # Fix all the tables where the bad key appears psql --username=nfldb nfldb --command="UPDATE play SET pos_team = 'JAC' WHERE pos_team = 'JAX'" # Delete the team with the bad key psql --username=nfldb nfldb --command="DELETE FROM team WHERE team_id = 'JAX'"