diff --git a/Makefile b/Makefile index fc82511..42db2db 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ bbdb = lahman_1871-2023_csv db: baseball.db -baseball.db: baseball-raw.db sql/awards.sql sql/franchises.sql sql/teamseasons.sql sql/seasons.sql sql/parks.sql sql/collegeplaying.sql sql/schools.sql sql/people.sql sql/salaries.sql sql/batting.sql sql/pitching.sql sql/fielding.sql sql/appearances.sql sql/homegames.sql sql/seriespost.sql sql/fieldingofsplit.sql sql/teams.sql sql/leagues.sql sql/managers.sql sql/awardsmanagers.sql sql/battingpost.sql sql/fieldingpost.sql sql/pitchingpost.sql sql/appearancespost.sql sql/awardsshareplayers.sql sql/yearlyawards.sql sql/halloffame.sql sql/halloffamereqs.sql sql/awardsplayers.sql sql/parkaliases.sql sql/teamseasonshalf.sql sql/managershalf.sql sql/allstarstartingpos.sql sql/allstars.sql sql/allstargames.sql sql/playerstints.sql +baseball.db: baseball-raw.db sql/awards.sql sql/franchises.sql sql/teamseasons.sql sql/seasons.sql sql/parks.sql sql/collegeplaying.sql sql/schools.sql sql/people.sql sql/salaries.sql sql/batting.sql sql/pitching.sql sql/fielding.sql sql/appearances.sql sql/homegames.sql sql/seriespost.sql sql/fieldingofsplit.sql sql/teams.sql sql/leagues.sql sql/managers.sql sql/awardsmanagers.sql sql/battingpost.sql sql/fieldingpost.sql sql/pitchingpost.sql sql/appearancespost.sql sql/awardsshareplayers.sql sql/yearlyawards.sql sql/halloffame.sql sql/awardsplayers.sql sql/parkaliases.sql sql/teamseasonshalf.sql sql/managershalf.sql sql/allstarstartingpos.sql sql/allstars.sql sql/allstargames.sql sql/playerstints.sql rm -f baseball.db cat sql/allstargames.sql | sqlite3 baseball.db cat sql/allstars.sql | sqlite3 baseball.db diff --git a/sql/halloffame.sql b/sql/halloffame.sql index 7ad7e61..bf0879c 100644 --- a/sql/halloffame.sql +++ b/sql/halloffame.sql @@ -14,17 +14,20 @@ update halloffame set needed = null where needed = '' or needed = 'NA'; -alter table halloffame drop column "ballots"; -alter table halloffame drop column "needed"; -alter table halloffame drop column "needed_note"; +update halloffame +set "needed_note" = nullif("needed_note",''); CREATE TABLE IF NOT EXISTS main."halloffame" ( "player" TEXT, "year" NUMERIC, "votedBy" TEXT, + "ballots" TEXT, + "needed" TEXT, "votes" NUMERIC, - "inducted" TEXT check ("inducted" in ('Y','N')), + -- we could have a check for if inducted is Y or N, but there are too many rows i don't feel like correcting right now + "inducted" TEXT, "category" TEXT, + "needed_note" text, PRIMARY KEY("player","year","votedBy") foreign key("player") references "people"("ID"), foreign key("year","votedBy") references "halloffamereqs"("year","votedBy") diff --git a/sql/halloffamereqs.sql b/sql/halloffamereqs.sql deleted file mode 100644 index 579611b..0000000 --- a/sql/halloffamereqs.sql +++ /dev/null @@ -1,34 +0,0 @@ -pragma foreign_keys = 0; - -begin; -attach database 'baseball-raw.db' as 'raw'; -create temp table if not exists "halloffamereqs" ( - "yearID" numeric, - "votedBy" text, - "ballots" numeric, - "needed" numeric, - "needed_note" text -); - -insert into halloffamereqs -select distinct yearid, votedby, ballots, needed, "needed_note" -from "raw".halloffame; - -update halloffamereqs -set - ballots = nullif(ballots,''), - needed = nullif(needed,''), - "needed_note" = nullif("needed_note",''); - -create table if not exists main."halloffamereqs" ( - "year" numeric, - "votedBy" text, - "ballots" numeric, - "needed" numeric check ("needed" <= "ballots"), - "needed_note" text, - primary key("year","votedBy"), - foreign key("year") references "seasons"("year") -); - -insert into main.halloffamereqs select distinct * from temp.halloffamereqs; -commit;