2024-05-05 03:46:30 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2024 filifa
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2024-02-01 04:43:23 +00:00
|
|
|
pragma foreign_keys = 0;
|
|
|
|
|
2024-01-26 03:08:32 +00:00
|
|
|
begin;
|
2024-05-05 03:11:20 +00:00
|
|
|
attach database 'lahman-raw.db' as 'raw';
|
2024-01-31 06:09:39 +00:00
|
|
|
|
|
|
|
create temp table people as
|
|
|
|
select * from "raw".people;
|
|
|
|
|
2024-05-05 02:16:35 +00:00
|
|
|
alter table people drop column "ID";
|
|
|
|
|
2024-01-26 03:08:32 +00:00
|
|
|
-- insert some missing people
|
|
|
|
insert into people values
|
|
|
|
('thompan01', null, null, null, null, null, null, null, null, null, null, null, null, null, 'Thompson', null, null, null, null, null, '1875-04-26', '1875-05-17', null, 'thompan01');
|
2024-01-31 06:09:39 +00:00
|
|
|
|
2024-05-05 02:16:35 +00:00
|
|
|
delete from people
|
|
|
|
where playerID = 'kellyho99';
|
|
|
|
|
2025-08-06 23:07:49 +00:00
|
|
|
delete from people
|
|
|
|
where playerID = 'frazge99';
|
|
|
|
|
|
|
|
update people
|
|
|
|
set bbrefID = 'frazege99'
|
|
|
|
where playerID = 'frazege99';
|
|
|
|
|
2024-02-02 01:45:40 +00:00
|
|
|
update people
|
2024-02-02 03:32:09 +00:00
|
|
|
set
|
2024-02-04 22:20:07 +00:00
|
|
|
birthcountry = nullif(birthcountry, ''),
|
|
|
|
birthstate = nullif(birthstate, ''),
|
|
|
|
birthcity = nullif(birthcity, ''),
|
2024-02-02 03:32:09 +00:00
|
|
|
birthYear = nullif(birthYear, ''),
|
|
|
|
birthMonth = nullif(birthMonth, ''),
|
|
|
|
birthDay = nullif(birthDay, ''),
|
|
|
|
deathYear = nullif(deathYear, ''),
|
|
|
|
deathMonth = nullif(deathMonth, ''),
|
|
|
|
deathDay = nullif(deathDay, ''),
|
2024-02-04 22:20:07 +00:00
|
|
|
deathcountry = nullif(deathcountry, ''),
|
|
|
|
deathstate = nullif(deathstate, ''),
|
|
|
|
deathcity = nullif(deathcity, ''),
|
2024-02-02 03:32:09 +00:00
|
|
|
weight = nullif(weight, ''),
|
|
|
|
height = nullif(height, ''),
|
|
|
|
bats = nullif(bats, ''),
|
|
|
|
throws = nullif(throws, ''),
|
|
|
|
debut = nullif(debut, ''),
|
|
|
|
finalGame = nullif(finalGame, ''),
|
|
|
|
bbrefID = nullif(bbrefid, ''),
|
|
|
|
retroID = nullif(retroid, '');
|
2024-02-02 01:45:40 +00:00
|
|
|
|
2025-08-06 23:08:08 +00:00
|
|
|
-- we don't know exactly when Alfredo Cabrera died
|
|
|
|
update people
|
|
|
|
set deathMonth = null
|
|
|
|
where deathMonth = 0;
|
|
|
|
|
|
|
|
update people
|
|
|
|
set deathDay = null
|
|
|
|
where deathDay = 0;
|
|
|
|
|
2024-02-02 01:45:40 +00:00
|
|
|
update people
|
2024-02-02 03:32:09 +00:00
|
|
|
set throws = 'B'
|
|
|
|
where throws = 'S';
|
2024-02-02 01:45:40 +00:00
|
|
|
|
2024-01-31 06:09:39 +00:00
|
|
|
CREATE TABLE main."people" (
|
|
|
|
"ID" text,
|
|
|
|
"birthYear" NUMERIC,
|
2024-02-02 03:32:09 +00:00
|
|
|
"birthMonth" NUMERIC check ("birthMonth" in (1,2,3,4,5,6,7,8,9,10,11,12)),
|
|
|
|
"birthDay" NUMERIC check ("birthDay" between 1 and 31),
|
2024-01-31 06:09:39 +00:00
|
|
|
"birthCountry" text,
|
|
|
|
"birthState" text,
|
|
|
|
"birthCity" text,
|
2024-02-02 03:32:09 +00:00
|
|
|
"deathYear" numeric,
|
|
|
|
"deathMonth" numeric check ("deathMonth" in (1,2,3,4,5,6,7,8,9,10,11,12)),
|
|
|
|
"deathDay" numeric check ("deathDay" between 1 and 31),
|
2024-01-31 06:09:39 +00:00
|
|
|
"deathCountry" text,
|
|
|
|
"deathState" text,
|
|
|
|
"deathCity" text,
|
|
|
|
"nameFirst" text,
|
|
|
|
"nameLast" text,
|
|
|
|
"nameGiven" text,
|
2024-02-02 03:32:09 +00:00
|
|
|
"weight" NUMERIC check ("weight" > 0),
|
|
|
|
"height" NUMERIC check ("height" > 0),
|
|
|
|
"bats" text check ("bats" in ('L','R','B')),
|
|
|
|
"throws" text check ("throws" in ('L','R','B')),
|
|
|
|
"debut" text check (unixepoch("debut") <= unixepoch("finalGame")),
|
2024-05-05 02:16:35 +00:00
|
|
|
"bbrefID" text unique,
|
2024-01-31 06:09:39 +00:00
|
|
|
"finalGame" text,
|
2024-02-02 01:45:40 +00:00
|
|
|
"retroID" text unique,
|
2024-01-31 06:09:39 +00:00
|
|
|
primary key("ID")
|
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO main."people" SELECT DISTINCT * FROM temp."people";
|
2024-01-26 03:08:32 +00:00
|
|
|
commit;
|