move hall of fame tables

This commit is contained in:
2024-01-28 19:07:59 -06:00
parent dfd2b78fb2
commit 8583b6332f
5 changed files with 36 additions and 27 deletions

View File

@@ -6,4 +6,8 @@ where ballots = '' or ballots = 'NA';
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";
commit;

View File

@@ -1,18 +1,14 @@
begin;
attach database 'baseball-raw.db' as 'raw';
create table if not exists "halloffamereqs" (
"yearID" numeric,
"votedBy" text,
"ballots" numeric,
"needed" numeric,
"needed_note" text,
primary key("yearID","votedBy")
"needed_note" text
);
insert into halloffamereqs
select distinct yearid, votedby, ballots, needed, "needed_note"
from halloffame;
alter table halloffame drop column "ballots";
alter table halloffame drop column "needed";
alter table halloffame drop column "needed_note";
from "raw".halloffame;
commit;

View File

@@ -1,19 +0,0 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_halloffame" (
"playerID" TEXT,
"yearID" NUMERIC,
"votedBy" TEXT,
"ballots" NUMERIC,
"needed" NUMERIC,
"votes" NUMERIC,
"inducted" TEXT,
"category" TEXT,
"needed_note" TEXT,
PRIMARY KEY("playerID","yearID","votedBy")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_halloffame" SELECT DISTINCT * FROM "halloffame";
DROP TABLE "halloffame";
ALTER TABLE "pk_halloffame" RENAME TO "halloffame";
COMMIT;

View File

@@ -539,4 +539,30 @@ create table if not exists "yearlyawards" (
);
insert into yearlyawards select distinct * from "transformed"."yearlyawards";
CREATE TABLE IF NOT EXISTS "halloffame" (
"player" TEXT,
"year" NUMERIC,
"votedBy" TEXT,
"votes" NUMERIC,
"inducted" TEXT,
"category" TEXT,
PRIMARY KEY("player","year","votedBy")
foreign key("player") references "people"("ID"),
foreign key("year","votedBy") references "halloffamereqs"("year","votedBy")
);
insert into halloffame select distinct * from "transformed".halloffame;
create table if not exists "halloffamereqs" (
"year" numeric,
"votedBy" text,
"ballots" numeric,
"needed" numeric,
"needed_note" text,
primary key("year","votedBy"),
foreign key("year") references "seasons"("year")
);
insert into halloffamereqs select distinct * from "transformed".halloffamereqs;
COMMIT;