lahmanlite/sql/keys/halloffame.sql

20 lines
475 B
PL/PgSQL

BEGIN;
CREATE TABLE IF NOT EXISTS "pk_halloffame" (
"playerID" TEXT,
"yearID" NUMERIC,
"votedBy" TEXT,
"ballots" NUMERIC,
"needed" NUMERIC,
"votes" NUMERIC,
"inducted" TEXT,
"category" TEXT,
"needed_note" TEXT,
PRIMARY KEY("playerID","yearID","votedBy")
foreign key("playerID") references "people"("playerID")
);
INSERT INTO "pk_halloffame" SELECT DISTINCT * FROM "halloffame";
DROP TABLE "halloffame";
ALTER TABLE "pk_halloffame" RENAME TO "halloffame";
COMMIT;