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-05-05 02:16:35 +00:00
|
|
|
alter table "homegames" drop column "leaguekey";
|
2024-01-28 04:53:07 +00:00
|
|
|
|
|
|
|
update homegames
|
2024-05-05 02:16:35 +00:00
|
|
|
set "teamkey" = 'WS9'
|
|
|
|
where "teamkey" = 'WAS' and "yearkey" between 1891 and 1899;
|
2024-01-28 04:53:07 +00:00
|
|
|
|
|
|
|
update homegames
|
2024-05-05 02:16:35 +00:00
|
|
|
set "teamkey" = 'PHP'
|
|
|
|
where "teamkey" = 'PH4' and "yearkey" 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;
|