DROP TABLE IF EXISTS character_history;
CREATE TABLE character_history (
	id         INTEGER PRIMARY KEY,
	char_id    INTEGER NOT NULL DEFAULT 0,
	type       TEXT    NOT NULL DEFAULT 'None',
	subtype    TEXT    NOT NULL DEFAULT 'None',
	value      INTEGER NOT NULL DEFAULT 0,
	value2     INTEGER NOT NULL DEFAULT 0,
	location   TEXT    DEFAULT '',
	event_id   INTEGER NOT NULL DEFAULT 0,
	event_date INTEGER NOT NULL DEFAULT 0,
	UNIQUE(char_id, type, subtype, value),
	FOREIGN KEY (char_id) REFERENCES characters(id) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE INDEX idx_character_history_char_id_type_subtype ON character_history(char_id, type, subtype);
