2024-02-01 04:43:23 +00:00
|
|
|
pragma foreign_keys = 0;
|
|
|
|
|
2024-01-26 19:27:58 +00:00
|
|
|
begin;
|
2024-01-31 06:09:39 +00:00
|
|
|
attach database 'baseball-raw.db' as 'raw';
|
|
|
|
|
|
|
|
create temp table homegames as
|
|
|
|
select * from "raw".homegames;
|
|
|
|
|
2024-01-26 19:27:58 +00:00
|
|
|
alter table "homegames" drop column "league.key";
|
2024-01-28 04:53:07 +00:00
|
|
|
|
|
|
|
update homegames
|
|
|
|
set "team.key" = 'WS9'
|
|
|
|
where "team.key" = 'WAS' and "year.key" between 1891 and 1899;
|
|
|
|
|
|
|
|
update homegames
|
|
|
|
set "team.key" = 'PHP'
|
|
|
|
where "team.key" = 'PH4' and "year.key" between 1890 and 1891;
|
2024-01-31 06:09:39 +00:00
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS main."homegames" (
|
|
|
|
"year" NUMERIC,
|
|
|
|
"team" TEXT,
|
|
|
|
"park" TEXT,
|
2024-02-02 02:48:12 +00:00
|
|
|
"first" TEXT check(unixepoch("first") <= unixepoch("last")),
|
2024-01-31 06:09:39 +00:00
|
|
|
"last" TEXT,
|
|
|
|
"games" NUMERIC,
|
|
|
|
"openings" NUMERIC,
|
|
|
|
"attendance" NUMERIC,
|
|
|
|
PRIMARY KEY("year","team","park"),
|
|
|
|
foreign key("park") references "parks"("ID"),
|
|
|
|
foreign key("year","team") references "teamseasons"("year","team")
|
|
|
|
);
|
|
|
|
|
|
|
|
insert into main.homegames select distinct * from temp."homegames";
|
2024-01-26 19:27:58 +00:00
|
|
|
commit;
|