DROP TABLE IF EXISTS character_mail;
CREATE TABLE character_mail (
	id              INTEGER PRIMARY KEY,
	player_to_id    INTEGER NOT NULL DEFAULT 0,
	player_from     TEXT    NOT NULL DEFAULT '',
	subject         TEXT    NOT NULL DEFAULT '',
	mail_body       TEXT,
	already_read    INTEGER NOT NULL DEFAULT 0,
	mail_type       INTEGER NOT NULL DEFAULT 0,
	coin_copper     INTEGER NOT NULL DEFAULT 0,
	coin_silver     INTEGER NOT NULL DEFAULT 0,
	coin_gold       INTEGER NOT NULL DEFAULT 0,
	coin_plat       INTEGER NOT NULL DEFAULT 0,
	stack           INTEGER NOT NULL DEFAULT 0,
	postage_cost    INTEGER NOT NULL DEFAULT 0,
	attachment_cost INTEGER NOT NULL DEFAULT 0,
	char_item_id    INTEGER NOT NULL DEFAULT 0,
	time_sent       INTEGER NOT NULL DEFAULT 0,
	expire_time     INTEGER NOT NULL DEFAULT 0,
	FOREIGN KEY (player_to_id) REFERENCES characters(id) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE INDEX idx_character_mail_player_to_id ON character_mail(player_to_id);
