Skip to content

Instantly share code, notes, and snippets.

@werebus
Last active August 29, 2015 13:56
Show Gist options
  • Save werebus/9190972 to your computer and use it in GitHub Desktop.
Save werebus/9190972 to your computer and use it in GitHub Desktop.
Pathfinder spells -> postgres
CREATE TABLE spells (
name varchar(255) unique not null,
school varchar(255),
subschool varchar(255),
descriptor varchar(255),
spell_level varchar(255),
casting_time varchar(255),
components varchar(255),
costly_components boolean,
range varchar(255),
area varchar(255),
effect varchar(255),
targets varchar(255),
duration varchar(255),
dismissible boolean,
shapeable boolean,
saving_throw varchar(255),
spell_resistence varchar(255),
description text,
description_formated text,
source varchar(255),
full_text text,
verbal boolean,
somatic boolean,
material boolean,
focus boolean,
divine_focus boolean,
sor integer,
wiz integer,
cleric integer,
druid integer,
ranger integer,
bard integer,
paladin integer,
alchemist integer,
summoner integer,
witch integer,
inquisitor integer,
oracle integer,
antipaladin integer,
magus integer,
adept integer,
deity varchar(255),
SLA_Level integer,
domain varchar(255),
short_description text,
acid boolean,
air boolean,
chaotic boolean,
cold boolean,
curse boolean,
darkness boolean,
death boolean,
disease boolean,
earth boolean,
electricity boolean,
emotion boolean,
evil boolean,
fear boolean,
fire boolean,
force boolean,
good boolean,
language_dependent boolean,
lawful boolean,
light boolean,
mind_affecting boolean,
pain boolean,
poison boolean,
shadow boolean,
sonic boolean,
water boolean,
linktext varchar(255),
id integer not null primary key,
material_costs float,
bloodline varchar(255),
patron varchar(255),
mythic_text text,
augmented text,
mythic boolean
);
COPY spells FROM 'spell_full.csv' DELIMITER ',' NULL 'NULL' CSV HEADER ;
/* Convenience function for books we're using. Use in WHERE clauses
/ e.g "SELECT * FROM spells WHERE core_rules(source);" */
CREATE FUNCTION core_rules(book varchar)
RETURNS boolean AS $$
BEGIN
IF (book = 'APG' OR book = 'PFRPG Core' OR book = 'Ultimate Combat' OR book = 'Ultimate Magic')
THEN
RETURN true;
ELSE
RETURN false;
END IF;
END; $$
LANGUAGE PLPGSQL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment