begin;
attach database 'baseball-raw.db' as 'raw';

create temp table halloffame as
select * from "raw".halloffame;

update halloffame
set ballots = null
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";

CREATE TABLE IF NOT EXISTS main."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 main.halloffame select distinct * from temp.halloffame;
commit;
