DROP TABLE IF EXISTS guild_members;
CREATE TABLE guild_members (
	id                     INTEGER PRIMARY KEY,
	guild_id               INTEGER NOT NULL DEFAULT 0,
	char_id                INTEGER NOT NULL DEFAULT 0,
	recruiter_id           INTEGER NOT NULL DEFAULT 0,
	guild_status           INTEGER NOT NULL DEFAULT 0,
	points                 REAL NOT NULL DEFAULT 0,
	rank_id                INTEGER NOT NULL DEFAULT 7,
	member_flags           INTEGER NOT NULL DEFAULT 0,
	join_date              INTEGER NOT NULL DEFAULT 0,
	note                   TEXT,
	officer_note           TEXT,
	recruiting_message     TEXT,
	recruiter_picture_data BLOB,
	UNIQUE(guild_id, char_id),
	FOREIGN KEY (guild_id) REFERENCES guilds(id) ON DELETE CASCADE ON UPDATE CASCADE,
	FOREIGN KEY (char_id) REFERENCES characters(id) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE INDEX idx_guild_members_char_id ON guild_members(char_id);
