move managers

This commit is contained in:
2024-01-27 23:14:56 -06:00
parent 00f197d89f
commit 3a60d30ff8
5 changed files with 30 additions and 24 deletions

View File

@@ -1,4 +0,0 @@
begin;
alter table managers drop column "lgID";
alter table managers drop column "rank";
commit;

View File

@@ -1,19 +0,0 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_managers" (
"playerID" TEXT,
"yearID" NUMERIC,
"teamID" TEXT,
"lgID" TEXT,
"inseason" NUMERIC,
"G" NUMERIC,
"W" NUMERIC,
"L" NUMERIC,
"rank" NUMERIC,
"plyrMgr" TEXT,
PRIMARY KEY("playerID","yearID","teamID","inseason"),
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_managers" SELECT DISTINCT * FROM "managers";
DROP TABLE "managers";
ALTER TABLE "pk_managers" RENAME TO "managers";
COMMIT;

View File

@@ -356,4 +356,20 @@ create table if not exists "leagues" (
);
insert into leagues select distinct * from "transformed"."leagues";
CREATE TABLE IF NOT EXISTS "managers" (
"ID" TEXT,
"year" NUMERIC,
"team" TEXT,
"inseason" NUMERIC,
"G" NUMERIC,
"W" NUMERIC,
"L" NUMERIC,
"plyrMgr" TEXT,
PRIMARY KEY("ID","year","team","inseason"),
foreign key("ID") references "people"("ID"),
foreign key("year","team") references "teamseasons"("year","team")
);
insert into managers select distinct * from "transformed"."managers";
COMMIT;

12
sql/managers.sql Normal file
View File

@@ -0,0 +1,12 @@
begin;
alter table managers drop column "lgID";
alter table managers drop column "rank";
update managers
set teamid = 'WS9'
where teamid = 'WAS' and yearid between 1891 and 1899;
update managers
set teamid = 'PHP'
where teamid = 'PH4' and yearid between 1890 and 1891;
commit;