move hall of fame tables
This commit is contained in:
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
26
sql/load.sql
26
sql/load.sql
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user