buddy, uid, buddy ) AS uid, IF( uid < buddy, uid, buddy ) AS buddy, timestamp, %d, 1 FROM {buddylist}", $rtid, time() ); db_query( 'INSERT INTO {user_relationships} (rid, rtid, requester_id, requestee_id, created_at, updated_at, approved) SELECT rid, rtid, requester_id, requestee_id, created_at, updated_at, approved FROM {user_relationship_migration}' ); db_query( 'INSERT INTO {user_relationships} (rid, rtid, requester_id, requestee_id, created_at, updated_at, approved) SELECT rid, rtid, requestee_id, requester_id, created_at, updated_at, approved FROM {user_relationship_migration}' ); _user_relationship_set_next_id(db_result(db_query("SELECT MAX(rid) FROM {user_relationships}"))); db_query('DROP TABLE {user_relationship_migration}'); db_query('UNLOCK TABLES'); return TRUE; } function _user_relationship_set_next_id($id) { $name = db_prefix_tables('{user_relationships}_id'); db_query('LOCK TABLES {sequences} WRITE'); db_query("REPLACE INTO {sequences} VALUES ('%s', %d)", $name, $id); db_query('UNLOCK TABLES'); }