pragma foreign_keys = 0;

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

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

alter table managershalf drop column "lgID";
alter table managershalf drop column "rank";

update managershalf
set teamid = 'WS9'
where yearid = 1892 and teamid = 'WAS';

CREATE TABLE IF NOT EXISTS main."managershalf" (
	"ID"	TEXT,
	"year"	NUMERIC,
	"team"	TEXT,
	"inseason"	NUMERIC,
	"half"	NUMERIC,
	"G"	NUMERIC,
	"W"	NUMERIC,
	"L"	NUMERIC,
	PRIMARY KEY("ID","year","team","inseason","half"),
	foreign key("ID","year","team","inseason") references "managers"("ID","year","team","inseason")
);

insert into main.managershalf select distinct * from temp.managershalf;
commit;
