2024-02-01 04:43:23 +00:00
|
|
|
pragma foreign_keys = 0;
|
|
|
|
|
2024-01-27 18:58:48 +00:00
|
|
|
begin;
|
2024-01-29 01:07:59 +00:00
|
|
|
attach database 'baseball-raw.db' as 'raw';
|
2024-01-31 06:09:39 +00:00
|
|
|
create temp table if not exists "halloffamereqs" (
|
2024-01-27 18:58:48 +00:00
|
|
|
"yearID" numeric,
|
|
|
|
"votedBy" text,
|
|
|
|
"ballots" numeric,
|
|
|
|
"needed" numeric,
|
2024-01-29 01:07:59 +00:00
|
|
|
"needed_note" text
|
2024-01-27 18:58:48 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
insert into halloffamereqs
|
|
|
|
select distinct yearid, votedby, ballots, needed, "needed_note"
|
2024-01-29 01:07:59 +00:00
|
|
|
from "raw".halloffame;
|
2024-01-31 06:09:39 +00:00
|
|
|
|
2024-02-02 02:48:12 +00:00
|
|
|
update halloffamereqs
|
|
|
|
set ballots = null
|
|
|
|
where ballots = "";
|
|
|
|
|
|
|
|
update halloffamereqs
|
|
|
|
set needed = null
|
|
|
|
where needed = "";
|
|
|
|
|
2024-01-31 06:09:39 +00:00
|
|
|
create table if not exists main."halloffamereqs" (
|
|
|
|
"year" numeric,
|
|
|
|
"votedBy" text,
|
|
|
|
"ballots" numeric,
|
2024-02-02 02:48:12 +00:00
|
|
|
"needed" numeric check ("needed" <= "ballots"),
|
2024-01-31 06:09:39 +00:00
|
|
|
"needed_note" text,
|
|
|
|
primary key("year","votedBy"),
|
|
|
|
foreign key("year") references "seasons"("year")
|
|
|
|
);
|
|
|
|
|
|
|
|
insert into main.halloffamereqs select distinct * from temp.halloffamereqs;
|
2024-01-27 18:58:48 +00:00
|
|
|
commit;
|