 INSERT INTO specials VALUES('weapon', 'multi', 'Crit Multiplier'); -- varcbonus
 INSERT INTO specials VALUES('ammo', 'dice', 'Damage Dice'); -- vardice
 CREATE TABLE items(
-item_id serial PRIMARY KEY
-,item_name varchar(100) NOT NULL
-,keywords varchar(100)
-,weight integer
-,c_value integer
-,item_type varchar(10) REFERENCES item_types(type_abbr)
-,attrib1 varchar(25) REFERENCES attribs(attrib_abbr)
-,attrib1_value integer
-,attrib2 varchar(25) REFERENCES attribs(attrib_abbr)
-,attrib2_value integer
-,from_zone varchar(25) REFERENCES zones(zone_abbr)
-,from_mob varchar(150) REFERENCES mobs(mob_name)
-,no_identify boolean
-,is_rare boolean
-,from_store boolean
-,from_quest boolean
-,for_quest boolean
-,from_invasion boolean
-,out_of_game boolean
-,short_stats varchar(450)
-,long_stats varchar(900)
-,full_stats text
-,comments text
-,last_id date
-,tsv tsvector
+	item_id serial PRIMARY KEY
+	,item_name varchar(100) NOT NULL
+	,keywords varchar(100)
+	,weight integer
+	,c_value integer
+	,item_type varchar(10) REFERENCES item_types(type_abbr)
+	,attrib1 varchar(25) REFERENCES attribs(attrib_abbr)
+	,attrib1_value integer
+	,attrib2 varchar(25) REFERENCES attribs(attrib_abbr)
+	,attrib2_value integer
+	,from_zone varchar(25) REFERENCES zones(zone_abbr)
+	,from_mob varchar(150) REFERENCES mobs(mob_name)
+	,no_identify boolean
+	,is_rare boolean
+	,from_store boolean
+	,from_quest boolean
+	,for_quest boolean
+	,from_invasion boolean
+	,out_of_game boolean
+	,short_stats varchar(450)
+	,long_stats varchar(900)
+	,full_stats text
+	,comments text
+	,last_id date
+	,tsv tsvector
 );
 CREATE INDEX idx_item_name ON items (item_name);
 UPDATE items SET tsv =

CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE
	ON items FOR EACH ROW EXECUTE PROCEDURE
	tsvector_update_trigger(tsv, 'pg_catalog.english', item_name, keywords);
CREATE TABLE item_procs(item_id integer REFERENCES items(item_id), proc_name text,
proc_type varchar(25), proc_desc varchar(25), proc_trig varchar(25), proc_effect varchar(25),
PRIMARY KEY (item_id, proc_name));
CREATE TABLE item_slots(item_id integer REFERENCES items(item_id), slot_abbr varchar(10)
REFERENCES slots(slot_abbr), PRIMARY KEY (item_id, slot_abbr));
CREATE TABLE item_flags(item_id integer REFERENCES items(item_id), flag_abbr varchar(10)
REFERENCES flags(flag_abbr), PRIMARY KEY (item_id, flag_abbr));
CREATE TABLE item_restricts(item_id integer REFERENCES items(item_id), restrict_abbr varchar(10)
REFERENCES restricts(restrict_abbr), PRIMARY KEY (item_id, restrict_abbr));
CREATE TABLE item_resists(item_id integer REFERENCES items(item_id), resist_abbr varchar(10)
REFERENCES resists(resist_abbr), resist_value integer, PRIMARY KEY (item_id, resist_abbr));
CREATE TABLE item_effects(item_id integer REFERENCES items(item_id), effect_abbr varchar(10)
REFERENCES effects(effect_abbr), PRIMARY KEY (item_id, effect_abbr));
CREATE TABLE item_specials(item_id integer REFERENCES items(item_id), item_type varchar(10),
spec_abbr varchar(10), spec_value varchar(30),
FOREIGN KEY (item_type, spec_abbr) REFERENCES specials (item_type, spec_abbr),
PRIMARY KEY (item_id, item_type, spec_abbr));
CREATE TABLE item_enchants(item_id integer REFERENCES items(item_id), ench_name varchar(25)
REFERENCES enchants(ench_name), dam_pct integer, freq_pct integer,
sv_mod integer, duration integer, PRIMARY KEY (item_id, ench_name));

INSERT INTO resists VALUES('neg', 'Neg', 'Negative');
INSERT INTO resists VALUES('pos', 'Pos', 'Positive');
INSERT INTO resists VALUES('sonic', 'Sonic', 'Sonic');
CREATE TABLE restricts(
	restrict_abbr varchar(10) PRIMARY KEY
	,restrict_name varchar(25)
);
INSERT INTO restricts VALUES('!goodrace', 'ANTI-GOODRACE');
INSERT INTO restricts VALUES('!evilrace', 'ANTI-EVILRACE');
INSERT INTO restricts VALUES('!fighter', 'NO-WARRIOR');
INSERT INTO restricts VALUES('!thief', 'NO-THIEF');
INSERT INTO restricts VALUES('!priest', 'NO-CLERIC');
INSERT INTO restricts VALUES('!mage', 'NO-MAGE');
INSERT INTO restricts VALUES('!good', 'ANTI-GOOD');
INSERT INTO restricts VALUES('!neut', 'ANTI-NEUTRAL');
