remove halloffamereqs table due to 2024 changes
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user