-- Add the type to the composite key for conversation_tags
ALTER TABLE conversation_tags RENAME TO conversation_tags_old;
CREATE TABLE conversation_tags(
	account_id TEXT NOT NULL,
	conversation_id TEXT NOT NULL,
	tag TEXT NOT NULL,
	conversation_type INTEGER DEFAULT 0,

	PRIMARY KEY(account_id, conversation_id, conversation_type, tag)
) STRICT;
INSERT INTO conversation_tags SELECT *, 0 FROM conversation_tags_old;
DROP TABLE conversation_tags_old;

-- Add the type to the composite key for conversation_members
ALTER TABLE conversation_members RENAME TO conversation_members_old;
CREATE TABLE conversation_members(
	account_id TEXT NOT NULL,
	contact_id TEXT NOT NULL,
	conversation_id TEXT NOT NULL,
	nickname TEXT,
	color TEXT,
	conversation_type INTEGER DEFAULT 0,

	PRIMARY KEY(account_id, conversation_id, conversation_type, contact_id)
) STRICT;
INSERT INTO conversation_members SELECT *, 0 FROM conversation_members_old;
DROP TABLE conversation_members_old;

-- Add the type to the composite key for conversation member tags
ALTER TABLE conversation_member_tags RENAME TO conversation_member_tags_old;
CREATE TABLE conversation_member_tags(
	account_id TEXT NOT NULL,
	contact_id TEXT NOT NULL,
	conversation_id TEXT NOT NULL,
	tag TEXT NOT NULL,
	conversation_type INTEGER DEFAULT 0,

	PRIMARY KEY(account_id, conversation_id, conversation_type, contact_id, tag)
) STRICT;
INSERT INTO conversation_member_tags SELECT *, 0 FROM conversation_member_tags_old;
DROP TABLE conversation_member_tags_old;

-- Add the type to the composite key for conversation member badges
ALTER TABLE conversation_member_badges RENAME TO conversation_member_badges_old;
CREATE TABLE conversation_member_badges(
	account_id TEXT NOT NULL,
	contact_id TEXT NOT NULL,
	conversation_id TEXT NOT NULL,
	badge_id TEXT NOT NULL,
	conversation_type INTEGER DEFAULT 0,

	PRIMARY KEY(account_id, conversation_id, conversation_type, contact_id, badge_id)
) STRICT;
INSERT INTO conversation_member_badges SELECT *, 0 FROM conversation_member_badges_old;
DROP TABLE conversation_member_badges_old;
