Add franchises

This commit is contained in:
Nick Griffey 2024-01-27 16:50:15 -06:00
parent 1e249f62ce
commit 6cc8f3aa3d
3 changed files with 15 additions and 14 deletions

View File

@ -4,9 +4,10 @@ bbdb = baseballdatabank-2023.1
db: baseball.db db: baseball.db
baseball.db: baseball-raw.db baseball.db: baseball-raw.db sql/people.sql sql/franchises.sql
rm -f baseball.db rm -f baseball.db
cat sql/people.sql | sqlite3 baseball.db cat sql/people.sql | sqlite3 baseball.db
cat sql/franchises.sql | sqlite3 baseball.db
sqlite3 baseball.db "VACUUM" sqlite3 baseball.db "VACUUM"
baseball-raw.db: baseball-raw.db:

13
sql/franchises.sql Normal file
View File

@ -0,0 +1,13 @@
BEGIN;
attach database 'baseball-raw.db' as 'raw';
CREATE TABLE IF NOT EXISTS "franchises" (
"franchID" TEXT,
"franchName" TEXT,
"active" TEXT,
"NAassoc" TEXT,
PRIMARY KEY("franchID")
);
insert into franchises
select distinct * from 'raw'.'teamsfranchises';
COMMIT;

View File

@ -1,13 +0,0 @@
BEGIN;
CREATE TABLE IF NOT EXISTS "pk_teamsfranchises" (
"franchID" TEXT,
"franchName" TEXT,
"active" TEXT,
"NAassoc" TEXT,
PRIMARY KEY("franchID")
);
INSERT INTO "pk_teamsfranchises" SELECT DISTINCT * FROM "teamsfranchises";
DROP TABLE "teamsfranchises";
ALTER TABLE "pk_teamsfranchises" RENAME TO "teamsfranchises";
COMMIT;