From 00f197d89f33295857819d578a4dfc74ec4c4ead Mon Sep 17 00:00:00 2001 From: Nick Griffey Date: Sat, 27 Jan 2024 22:53:07 -0600 Subject: [PATCH] fix foreign key violations cascading from fixing team ids --- sql/appearances.sql | 8 ++++++++ sql/batting.sql | 8 ++++++++ sql/fielding.sql | 8 ++++++++ sql/homegames.sql | 8 ++++++++ sql/pitching.sql | 8 ++++++++ 5 files changed, 40 insertions(+) diff --git a/sql/appearances.sql b/sql/appearances.sql index a1a6975..acb6e57 100644 --- a/sql/appearances.sql +++ b/sql/appearances.sql @@ -1,3 +1,11 @@ begin; alter table "appearances" drop column "lgID"; + +update appearances +set teamid = 'WS9' +where teamid = 'WAS' and yearid between 1891 and 1899; + +update appearances +set teamid = 'PHP' +where teamid = 'PH4' and yearid between 1890 and 1891; commit; diff --git a/sql/batting.sql b/sql/batting.sql index 45375ad..381dc72 100644 --- a/sql/batting.sql +++ b/sql/batting.sql @@ -1,3 +1,11 @@ begin; alter table batting drop column "lgID"; + +update batting +set teamid = 'WS9' +where teamid = 'WAS' and yearid between 1891 and 1899; + +update batting +set teamid = 'PHP' +where teamid = 'PH4' and yearid between 1890 and 1891; commit; diff --git a/sql/fielding.sql b/sql/fielding.sql index e04664e..832f00a 100644 --- a/sql/fielding.sql +++ b/sql/fielding.sql @@ -1,3 +1,11 @@ begin; alter table fielding drop column "lgID"; + +update fielding +set teamid = 'WS9' +where teamid = 'WAS' and yearid between 1891 and 1899; + +update fielding +set teamid = 'PHP' +where teamid = 'PH4' and yearid between 1890 and 1891; commit; diff --git a/sql/homegames.sql b/sql/homegames.sql index 500d3ed..37e7ce5 100644 --- a/sql/homegames.sql +++ b/sql/homegames.sql @@ -1,3 +1,11 @@ begin; alter table "homegames" drop column "league.key"; + +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; commit; diff --git a/sql/pitching.sql b/sql/pitching.sql index 596351b..53c13ad 100644 --- a/sql/pitching.sql +++ b/sql/pitching.sql @@ -1,3 +1,11 @@ begin; alter table pitching drop column "lgID"; + +update pitching +set teamid = 'WS9' +where teamid = 'WAS' and yearid between 1891 and 1899; + +update pitching +set teamid = 'PHP' +where teamid = 'PH4' and yearid between 1890 and 1891; commit;