23 lines
610 B
PL/PgSQL
23 lines
610 B
PL/PgSQL
pragma foreign_keys = 0;
|
|
|
|
begin;
|
|
attach database 'baseball-raw.db' as 'raw';
|
|
|
|
create temp table awardsplayers as
|
|
select * from "raw".awardsplayers;
|
|
alter table temp.awardsplayers drop column "tie";
|
|
|
|
CREATE TABLE IF NOT EXISTS main."awardsplayers" (
|
|
"player" TEXT,
|
|
"award" TEXT,
|
|
"year" NUMERIC,
|
|
"league" TEXT,
|
|
"notes" TEXT,
|
|
PRIMARY KEY("award","year","league","notes","player"),
|
|
foreign key("player") references "people"("ID"),
|
|
foreign key("award","year","league") references "yearlyawards"("award","year","league")
|
|
);
|
|
|
|
insert into main.awardsplayers select distinct * from temp.awardsplayers;
|
|
commit;
|