pragma foreign_keys = 0;

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

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

alter table "salaries" drop column "lgID";

CREATE TABLE IF NOT EXISTS main."salaries" (
	"year"	NUMERIC,
	"team"	TEXT,
	"player"	TEXT,
	"salary"	NUMERIC,
	PRIMARY KEY("year","player","team"),
	foreign key("player") references "people"("ID"),
	foreign key("year","team") references "teamseasons"("year","team")
);

insert into main.salaries select distinct * from temp."salaries";
commit;
