remove halloffamereqs table due to 2024 changes

This commit is contained in:
filifa 2024-05-04 21:07:53 -05:00
parent a067ff62b2
commit c643396e41
3 changed files with 8 additions and 39 deletions

View File

@ -4,7 +4,7 @@ bbdb = lahman_1871-2023_csv
db: baseball.db 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 rm -f baseball.db
cat sql/allstargames.sql | sqlite3 baseball.db cat sql/allstargames.sql | sqlite3 baseball.db
cat sql/allstars.sql | sqlite3 baseball.db cat sql/allstars.sql | sqlite3 baseball.db

View File

@ -14,17 +14,20 @@ update halloffame
set needed = null set needed = null
where needed = '' or needed = 'NA'; where needed = '' or needed = 'NA';
alter table halloffame drop column "ballots"; update halloffame
alter table halloffame drop column "needed"; set "needed_note" = nullif("needed_note",'');
alter table halloffame drop column "needed_note";
CREATE TABLE IF NOT EXISTS main."halloffame" ( CREATE TABLE IF NOT EXISTS main."halloffame" (
"player" TEXT, "player" TEXT,
"year" NUMERIC, "year" NUMERIC,
"votedBy" TEXT, "votedBy" TEXT,
"ballots" TEXT,
"needed" TEXT,
"votes" NUMERIC, "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, "category" TEXT,
"needed_note" text,
PRIMARY KEY("player","year","votedBy") PRIMARY KEY("player","year","votedBy")
foreign key("player") references "people"("ID"), foreign key("player") references "people"("ID"),
foreign key("year","votedBy") references "halloffamereqs"("year","votedBy") foreign key("year","votedBy") references "halloffamereqs"("year","votedBy")

View File

@ -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;