BEGIN TRANSACTION;

ALTER TABLE group_member RENAME TO old_group_member;

CREATE TABLE "group_member" (
	"id"	INTEGER NOT NULL UNIQUE,
	"group_id"	INTEGER NOT NULL,
	"user_id"	INTEGER NOT NULL,
	PRIMARY KEY("id" AUTOINCREMENT),
	UNIQUE("user_id","group_id"),
	FOREIGN KEY("group_id") REFERENCES "group"("id"),
	FOREIGN KEY("user_id") REFERENCES "user"("id")
);

INSERT INTO group_member (group_id, user_id) SELECT group_id, user_id FROM old_group_member;

DROP TABLE "old_group_member";

COMMIT;
