BEGIN;
CREATE TABLE IF NOT EXISTS "pk_teams" (
	"yearID"	NUMERIC,
	"lgID"	TEXT,
	"teamID"	TEXT,
	"franchID"	TEXT,
	"divID"	TEXT,
	"Rank"	NUMERIC,
	"G"	NUMERIC,
	"Ghome"	NUMERIC,
	"W"	NUMERIC,
	"L"	NUMERIC,
	"DivWin"	NUMERIC,
	"WCWin"	NUMERIC,
	"LgWin"	NUMERIC,
	"WSWin"	NUMERIC,
	"R"	NUMERIC,
	"AB"	NUMERIC,
	"H"	NUMERIC,
	"2B"	NUMERIC,
	"3B"	NUMERIC,
	"HR"	NUMERIC,
	"BB"	NUMERIC,
	"SO"	NUMERIC,
	"SB"	NUMERIC,
	"CS"	NUMERIC,
	"HBP"	NUMERIC,
	"SF"	NUMERIC,
	"RA"	NUMERIC,
	"ER"	NUMERIC,
	"ERA"	NUMERIC,
	"CG"	NUMERIC,
	"SHO"	NUMERIC,
	"SV"	NUMERIC,
	"IPouts"	NUMERIC,
	"HA"	NUMERIC,
	"HRA"	NUMERIC,
	"BBA"	NUMERIC,
	"SOA"	NUMERIC,
	"E"	NUMERIC,
	"DP"	NUMERIC,
	"FP"	NUMERIC,
	"name"	NUMERIC,
	"park"	NUMERIC,
	"attendance"	NUMERIC,
	"BPF"	NUMERIC,
	"PPF"	NUMERIC,
	"teamIDBR"	TEXT,
	"teamIDlahman45"	TEXT,
	"teamIDretro"	TEXT,
	PRIMARY KEY("yearID","franchID"),
	foreign key("franchID") references "teamsfranchises"("franchID")
);

INSERT INTO "pk_teams" SELECT DISTINCT * FROM "teams";
DROP TABLE "teams";
ALTER TABLE "pk_teams" RENAME TO "teams";
COMMIT;
