DROP TABLE IF EXISTS characters;
CREATE TABLE characters (
	id                     INTEGER PRIMARY KEY,
	account_id             INTEGER NOT NULL DEFAULT 0,
	server_id              INTEGER NOT NULL DEFAULT 0,
	name                   TEXT    NOT NULL DEFAULT '',
	race                   INTEGER NOT NULL DEFAULT 0,
	class                  INTEGER NOT NULL DEFAULT 0,
	gender                 INTEGER NOT NULL DEFAULT 0,
	deity                  INTEGER NOT NULL DEFAULT 0,
	body_size              REAL    NOT NULL DEFAULT 0,
	body_age               REAL    NOT NULL DEFAULT 0,
	current_zone_id        INTEGER NOT NULL DEFAULT 253,
	level                  INTEGER NOT NULL DEFAULT 1,
	tradeskill_class       INTEGER NOT NULL DEFAULT 0,
	tradeskill_level       INTEGER NOT NULL DEFAULT 1,
	soga_wing_type         INTEGER NOT NULL,
	soga_chest_type        INTEGER NOT NULL,
	soga_legs_type         INTEGER NOT NULL,
	soga_hair_type         INTEGER NOT NULL,
	soga_facial_hair_type  INTEGER NOT NULL DEFAULT 0,
	soga_model_type        INTEGER NOT NULL,
	legs_type              INTEGER NOT NULL,
	chest_type             INTEGER NOT NULL,
	wing_type              INTEGER NOT NULL,
	hair_type              INTEGER NOT NULL,
	facial_hair_type       INTEGER NOT NULL DEFAULT 0,
	model_type             INTEGER NOT NULL,
	x                      REAL    NOT NULL DEFAULT 0,
	y                      REAL    NOT NULL DEFAULT 0,
	z                      REAL    NOT NULL DEFAULT 0,
	heading                REAL    NOT NULL DEFAULT 0,
	instance_id            INTEGER NOT NULL DEFAULT 0,
	starting_city          INTEGER NOT NULL DEFAULT 1,
	deleted                INTEGER NOT NULL DEFAULT 0,
	unix_timestamp         INTEGER NOT NULL DEFAULT 0,
	created_date           INTEGER NOT NULL DEFAULT 0,
	last_played            INTEGER NOT NULL DEFAULT (strftime('%s', 'now')),
	last_saved             INTEGER NOT NULL DEFAULT 0,
	admin_status           INTEGER NOT NULL DEFAULT 0,
	is_online              INTEGER NOT NULL DEFAULT 0,
	group_id               INTEGER NOT NULL DEFAULT 0,
	alignment              INTEGER NOT NULL DEFAULT 0,
	first_world_login      INTEGER NOT NULL DEFAULT 0,
	zone_duplicating_id    INTEGER NOT NULL DEFAULT 0
);
CREATE INDEX idx_characters_name ON characters(name);
CREATE INDEX idx_characters_current_zone_id ON characters(current_zone_id);
CREATE INDEX idx_characters_account_id ON characters(account_id);
