BEGIN;
CREATE TABLE IF NOT EXISTS "pk_homegames" (
	"year.key"	NUMERIC,
	"league.key"	TEXT,
	"team.key"	TEXT,
	"park.key"	TEXT,
	"span.first"	TEXT,
	"span.last"	TEXT,
	"games"	NUMERIC,
	"openings"	NUMERIC,
	"attendance"	NUMERIC,
	PRIMARY KEY("year.key","team.key","park.key")
);

INSERT INTO "pk_homegames" SELECT DISTINCT * FROM "homegames";
DROP TABLE "homegames";
ALTER TABLE "pk_homegames" RENAME TO "homegames";
COMMIT;
