pragma foreign_keys = 0;

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

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

alter table parks drop column "park.alias";

-- insert some missing parks
insert into parks values
('ARL03', 'Globe Life Field', 'Arlington', 'TX', 'US'),
('BUF05', 'Sahlen Field', 'Buffalo', 'NY', 'US'),
('DUN01', 'TD Ballpark', 'Dunedin', 'FL', 'US'),
('DYE01', 'Field of Dreams', 'Dyersville', 'IA', 'US');

CREATE TABLE IF NOT EXISTS main."parks" (
	"ID"	TEXT,
	"name"	TEXT,
	"city"	TEXT,
	"state"	TEXT,
	"country"	TEXT,
	PRIMARY KEY("ID")
);

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