From 65f1425daf67c54bae340c630e3d296a37d15e54 Mon Sep 17 00:00:00 2001 From: James Miller Date: Tue, 6 Aug 2019 15:25:14 -0500 Subject: [PATCH 1/5] refactor out senses and traits into separate schema files --- gendb.sh | 4 ++++ schema/ancestries.sql | 22 ---------------------- schema/senses.sql | 9 +++++++++ schema/traits.sql | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 schema/senses.sql create mode 100644 schema/traits.sql diff --git a/gendb.sh b/gendb.sh index ac4ae0f..fea1c13 100755 --- a/gendb.sh +++ b/gendb.sh @@ -2,6 +2,10 @@ rm pf2.db echo 'loading schema' echo 'schema/abilityscores.sql' sqlite3 pf2.db < schema/abilityscores.sql +echo 'schema/traits.sql' +sqlite3 pf2.db < schema/traits.sql +echo 'schema/senses.sql' +sqlite3 pf2.db < schema/senses.sql echo 'schema/ancestries.sql' sqlite3 pf2.db < schema/ancestries.sql echo 'loading data' diff --git a/schema/ancestries.sql b/schema/ancestries.sql index 8c2df38..be596fb 100644 --- a/schema/ancestries.sql +++ b/schema/ancestries.sql @@ -39,12 +39,6 @@ CREATE TABLE ancestries_flaws ( FOREIGN KEY (abilityscores_id) REFERENCES abilityscores(abilityscores_id) ); -/* has partial data */ -CREATE TABLE visions ( - vision_id INTEGER PRIMARY KEY, - short_name TEXT NOT NULL UNIQUE, - description TEXT NOT NULL -); /* Need to figure out how to model heritages that also have reactions / feats etc.. */ @@ -65,22 +59,6 @@ CREATE TABLE ancestries_heritages ( FOREIGN KEY (heritage_id) REFERENCES heritages(heritage_id) ); -/* TODO can the description var be UNIQUE? */ -/* has partial data done */ -CREATE TABLE traits ( - trait_id INTEGER PRIMARY KEY, - -- short_name TEXT NOT NULL UNIQUE, - traittype INTEGER, - short_name TEXT NOT NULL, - description TEXT NOT NULL, - FOREIGN KEY (traittype) REFERENCES traittypes(traittypes_id) -); - -CREATE TABLE traittypes ( - traittype_id INTEGER PRIMARY KEY, - name TEXT NOT NULL -); - /* TODO THIS TABLE IS LIKELY NOT NEEDED. THANKS WES! */ CREATE TABLE heritages_traits ( diff --git a/schema/senses.sql b/schema/senses.sql new file mode 100644 index 0000000..106a3a4 --- /dev/null +++ b/schema/senses.sql @@ -0,0 +1,9 @@ +-- -*- mode:sql sql-product:sqlite -*- + +/* TODO change visions to a senses table */ + +CREATE TABLE visions ( + vision_id INTEGER PRIMARY KEY, + short_name TEXT NOT NULL UNIQUE, + description TEXT NOT NULL +); diff --git a/schema/traits.sql b/schema/traits.sql new file mode 100644 index 0000000..d3c99ad --- /dev/null +++ b/schema/traits.sql @@ -0,0 +1,17 @@ +-- -*- mode:sql sql-product:sqlite -*- + +CREATE TABLE traittypes ( + traittype_id INTEGER PRIMARY KEY, + name TEXT NOT NULL +); + +/* TODO can the description var be UNIQUE? */ +/* has partial data done */ +CREATE TABLE traits ( + trait_id INTEGER PRIMARY KEY, + traittype INTEGER, + short_name TEXT NOT NULL, + description TEXT NOT NULL, + FOREIGN KEY (traittype) REFERENCES traittypes(traittypes_id) +); + From 44c5454ab1df996a8a3b2d9bed238f4458c5360d Mon Sep 17 00:00:00 2001 From: James Miller Date: Tue, 6 Aug 2019 15:26:41 -0500 Subject: [PATCH 2/5] update gendb.bat --- gendb.bat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gendb.bat b/gendb.bat index 8fc2d21..5b31f56 100644 --- a/gendb.bat +++ b/gendb.bat @@ -3,6 +3,8 @@ del pf2.db :: Loading schema sqlite3 pf2.db < schema/abilityscores.sql +sqlite3 pf2.db < schema/traits.sql +sqlite3 pf2.db < schema/senses.sql sqlite3 pf2.db < schema/ancestries.sql :: Loading data From a044b5ef93fb92c33a25471b076729258f2374b2 Mon Sep 17 00:00:00 2001 From: James Miller Date: Tue, 6 Aug 2019 15:36:59 -0500 Subject: [PATCH 3/5] refactor out langs and sizes and new data to sizes --- data/sizes.sql | 14 +++++++------- gendb.bat | 1 + gendb.sh | 4 ++++ schema/ancestries.sql | 8 -------- schema/langs.sql | 6 ++++++ schema/sizes.sql | 10 ++++++++++ 6 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 schema/langs.sql create mode 100644 schema/sizes.sql diff --git a/data/sizes.sql b/data/sizes.sql index ab5e124..7b55b45 100644 --- a/data/sizes.sql +++ b/data/sizes.sql @@ -1,9 +1,9 @@ -- -*- mode:sql sql-product:sqlite -*- -INSERT INTO sizes (size_id, short_name) VALUES - (1, 'Tiny'), - (2, 'Small'), - (3, 'Medium'), - (4, 'Large'), - (5, 'Huge'), - (6, 'Gargantuan'); +INSERT INTO sizes (size_id, short_name, space_in_ft, reach_tall_ft, reach_long_ft) VALUES + (1,'Tiny',4,0,0), + (2,'Small',5,5,5), + (3,'Medium',5,5,5), + (4,'Large',10,10,5), + (5,'Huge',15,15,10), + (6,'Gargantuan',20,20,15); diff --git a/gendb.bat b/gendb.bat index 5b31f56..a4ee7c1 100644 --- a/gendb.bat +++ b/gendb.bat @@ -3,6 +3,7 @@ del pf2.db :: Loading schema sqlite3 pf2.db < schema/abilityscores.sql +sqlite3 pf2.db < schema/langs.sql sqlite3 pf2.db < schema/traits.sql sqlite3 pf2.db < schema/senses.sql sqlite3 pf2.db < schema/ancestries.sql diff --git a/gendb.sh b/gendb.sh index fea1c13..79a76d9 100755 --- a/gendb.sh +++ b/gendb.sh @@ -2,6 +2,10 @@ rm pf2.db echo 'loading schema' echo 'schema/abilityscores.sql' sqlite3 pf2.db < schema/abilityscores.sql +echo 'schema/sizes.sql' +sqlite3 pf2.db < schema/sizes.sql +echo 'schema/langs.sql' +sqlite3 pf2.db < schema/langs.sql echo 'schema/traits.sql' sqlite3 pf2.db < schema/traits.sql echo 'schema/senses.sql' diff --git a/schema/ancestries.sql b/schema/ancestries.sql index be596fb..5988b25 100644 --- a/schema/ancestries.sql +++ b/schema/ancestries.sql @@ -80,15 +80,7 @@ CREATE TABLE ancestries_traits ( FOREIGN KEY (trait_id) REFERENCES traits(trait_id) ); -CREATE TABLE sizes ( - size_id INTEGER PRIMARY KEY, - short_name TEXT NOT NULL UNIQUE -); -CREATE TABLE langs ( - lang_id INTEGER PRIMARY KEY, - short_name TEXT NOT NULL UNIQUE -); CREATE TABLE ancestries_langs ( id INTEGER PRIMARY KEY, diff --git a/schema/langs.sql b/schema/langs.sql new file mode 100644 index 0000000..8ed0406 --- /dev/null +++ b/schema/langs.sql @@ -0,0 +1,6 @@ +-- -*- mode:sql sql-product:sqlite -*- + +CREATE TABLE langs ( + lang_id INTEGER PRIMARY KEY, + short_name TEXT NOT NULL UNIQUE +); diff --git a/schema/sizes.sql b/schema/sizes.sql new file mode 100644 index 0000000..33b9596 --- /dev/null +++ b/schema/sizes.sql @@ -0,0 +1,10 @@ +-- -*- mode:sql sql-product:sqlite -*- + + +CREATE TABLE sizes ( + size_id INTEGER PRIMARY KEY, + short_name TEXT NOT NULL UNIQUE, + space_in_ft INTEGER NOT NULL, + reach_tall_ft INTEGER NOT NULL, + reach_long_ft INTEGER NOT NULL +); From a6f3b03d5065a22ec9bc2c13fe5f3af46636a5ee Mon Sep 17 00:00:00 2001 From: James Miller Date: Tue, 6 Aug 2019 15:39:08 -0500 Subject: [PATCH 4/5] move feats schema to new feats.sql file --- schema/ancestries.sql | 27 --------------------------- schema/feats.sql | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 27 deletions(-) create mode 100644 schema/feats.sql diff --git a/schema/ancestries.sql b/schema/ancestries.sql index 5988b25..d3430cd 100644 --- a/schema/ancestries.sql +++ b/schema/ancestries.sql @@ -1,16 +1,13 @@ -- -*- mode:sql sql-product:sqlite -*- /* - TODO Need to decide on whether to do a massive feats table, or to split feats into separate tables for general feats, ancestry feats, background feats, etc... I think one big feat table that has a feat type in it and then an ancestry_feat table that matches feats to ancestries, etc.. - */ - CREATE TABLE ancestries ( ancestry_id INTEGER PRIMARY KEY, short_name TEXT NOT NULL UNIQUE, @@ -80,8 +77,6 @@ CREATE TABLE ancestries_traits ( FOREIGN KEY (trait_id) REFERENCES traits(trait_id) ); - - CREATE TABLE ancestries_langs ( id INTEGER PRIMARY KEY, ancestry_id INTEGER NOT NULL, @@ -89,7 +84,6 @@ CREATE TABLE ancestries_langs ( FOREIGN KEY (ancestry_id) REFERENCES ancestries(ancestry_id), FOREIGN KEY (lang_id) REFERENCES langs(lang_id)); - CREATE TABLE ancestry_additionalangs ( id INTEGER PRIMARY KEY, ancestry_id INTEGER NOT NULL, @@ -97,24 +91,3 @@ CREATE TABLE ancestry_additionalangs ( FOREIGN KEY (ancestry_id) REFERENCES ancestries(ancestry_id), FOREIGN KEY (lang_id) REFERENCES langs(lang_id) ); - -/* Need to rethink how to model the various prerequisites */ - -CREATE TABLE feats ( - feat_id INTEGER PRIMARY KEY, - short_name TEXT NOT NULL UNIQUE, - prereq_feats INTEGER, - prereq_ability_scores INTEGER, - prereq_proficiency_ranks INTEGER, - frequency TEXT, - triggers TEXT, - reqs TEXT -); - -CREATE TABLE feats_traits ( - id INTEGER PRIMARY KEY, - feat_id INTEGER NOT NULL, - trait_id INTEGER NOT NULL, - FOREIGN KEY (feat_id) REFERENCES feats(feat_id), - FOREIGN KEY (trait_id) REFERENCES traits(trait_id) -); diff --git a/schema/feats.sql b/schema/feats.sql new file mode 100644 index 0000000..1b9cc25 --- /dev/null +++ b/schema/feats.sql @@ -0,0 +1,22 @@ +-- -*- mode:sql sql-product:sqlite -*- + +/* Need to rethink how to model the various prerequisites */ + +CREATE TABLE feats ( + feat_id INTEGER PRIMARY KEY, + short_name TEXT NOT NULL UNIQUE, + prereq_feats INTEGER, + prereq_ability_scores INTEGER, + prereq_proficiency_ranks INTEGER, + frequency TEXT, + triggers TEXT, + reqs TEXT +); + +CREATE TABLE feats_traits ( + id INTEGER PRIMARY KEY, + feat_id INTEGER NOT NULL, + trait_id INTEGER NOT NULL, + FOREIGN KEY (feat_id) REFERENCES feats(feat_id), + FOREIGN KEY (trait_id) REFERENCES traits(trait_id) +); From 2946a22bdc2c3b26358e69fc1c8e5bd4aa350986 Mon Sep 17 00:00:00 2001 From: James Miller Date: Tue, 6 Aug 2019 15:41:03 -0500 Subject: [PATCH 5/5] refactor feats to separate table and bring gendb up to date --- gendb.bat | 1 + gendb.sh | 2 ++ schema/feats.sql | 2 ++ 3 files changed, 5 insertions(+) diff --git a/gendb.bat b/gendb.bat index a4ee7c1..4a424f0 100644 --- a/gendb.bat +++ b/gendb.bat @@ -5,6 +5,7 @@ del pf2.db sqlite3 pf2.db < schema/abilityscores.sql sqlite3 pf2.db < schema/langs.sql sqlite3 pf2.db < schema/traits.sql +sqlite3 pf2.db < schema/feats.sql sqlite3 pf2.db < schema/senses.sql sqlite3 pf2.db < schema/ancestries.sql diff --git a/gendb.sh b/gendb.sh index 79a76d9..edda9dd 100755 --- a/gendb.sh +++ b/gendb.sh @@ -8,6 +8,8 @@ echo 'schema/langs.sql' sqlite3 pf2.db < schema/langs.sql echo 'schema/traits.sql' sqlite3 pf2.db < schema/traits.sql +echo 'schema/feats.sql' +sqlite3 pf2.db < schema/feats.sql echo 'schema/senses.sql' sqlite3 pf2.db < schema/senses.sql echo 'schema/ancestries.sql' diff --git a/schema/feats.sql b/schema/feats.sql index 1b9cc25..8a099e1 100644 --- a/schema/feats.sql +++ b/schema/feats.sql @@ -1,5 +1,7 @@ -- -*- mode:sql sql-product:sqlite -*- +/* MUST BE CALLED AFTER TRAITS TABLE IS FORMED */ + /* Need to rethink how to model the various prerequisites */ CREATE TABLE feats (