DROP TABLE IF EXISTS character_quests;
CREATE TABLE character_quests (
	id             INTEGER PRIMARY KEY,
	char_id        INTEGER NOT NULL DEFAULT 0,
	quest_id       INTEGER NOT NULL DEFAULT 0,
	quest_giver    INTEGER NOT NULL DEFAULT 0,
	given_date     INTEGER NOT NULL,
	completed_date INTEGER,
	current_quest  INTEGER NOT NULL DEFAULT 0,
	tracked        INTEGER NOT NULL DEFAULT 0,
	quest_flags    INTEGER NOT NULL DEFAULT 0,
	hidden         INTEGER NOT NULL DEFAULT 0,
	complete_count INTEGER NOT NULL DEFAULT 0,
	status_to_earn INTEGER NOT NULL DEFAULT 0,
	UNIQUE(char_id, quest_id),
	FOREIGN KEY (char_id) REFERENCES characters(id) ON DELETE CASCADE ON UPDATE CASCADE,
	FOREIGN KEY (quest_id) REFERENCES quests(quest_id) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE INDEX idx_character_quests_quest_id ON character_quests(quest_id);
