2024-01-31 22:43:23 -06:00
|
|
|
pragma foreign_keys = 0;
|
|
|
|
|
|
2024-01-27 21:19:48 -06:00
|
|
|
begin;
|
|
|
|
|
attach database 'baseball-raw.db' as 'raw';
|
2024-01-31 00:09:39 -06:00
|
|
|
create temp table if not exists teams (
|
2024-01-27 21:29:07 -06:00
|
|
|
"ID" text,
|
2024-01-27 21:19:48 -06:00
|
|
|
"franchise" text
|
|
|
|
|
);
|
|
|
|
|
|
2024-01-27 21:41:23 -06:00
|
|
|
insert into teams
|
2024-01-27 21:19:48 -06:00
|
|
|
select distinct teamid, franchid from "raw"."teams";
|
|
|
|
|
|
2024-01-27 21:41:23 -06:00
|
|
|
update teams
|
2024-01-27 21:29:07 -06:00
|
|
|
set ID = 'WS9'
|
|
|
|
|
where ID = 'WAS' and franchise = 'WAS';
|
2024-01-27 21:19:48 -06:00
|
|
|
|
2024-01-27 21:41:23 -06:00
|
|
|
update teams
|
2024-01-27 21:29:07 -06:00
|
|
|
set ID = 'PHP'
|
|
|
|
|
where ID = 'PH4' and franchise = 'PHQ';
|
2024-01-31 00:09:39 -06:00
|
|
|
|
|
|
|
|
create table if not exists main.teams (
|
|
|
|
|
"ID" text,
|
|
|
|
|
"franchise" text,
|
|
|
|
|
primary key("ID"),
|
|
|
|
|
foreign key("franchise") references "franchises"("ID")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
insert into main.teams select distinct * from temp."teams";
|
2024-01-27 21:19:48 -06:00
|
|
|
commit;
|